Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CLS
- #Gives the user access to the loop less then 1 an higher then 20.
- do {
- [int]$userMenuChoice = 0
- while ( $userMenuChoice -lt 1 -or $userMenuChoice -gt 26) {
- #writes down all the different options
- write-host `t""`t
- write-host -ForegroundColor 'Green' `t"* Troubleshooting tools"`t
- write-host -ForegroundColor 'Green' ------------------------------------
- write-host -ForegroundColor 'Yellow'`t"1. Ping your own host"
- write-host -ForegroundColor "Yellow"`t"2. Ping Google DNS"
- write-host -ForegroundColor "Yellow"`t"3. Test-connection"
- write-host -ForegroundColor "Yellow"`t"4. Test-netconnection on port"
- write-host -ForegroundColor "Yellow"`t"5. Traceroute"
- write-host -ForegroundColor "Yellow"`t"6. ARP network information"
- write-host -ForegroundColor "Yellow"`t"7. NSlookup"
- write-host -ForegroundColor 'Yellow'`t"8. Netstat"
- write-host -ForegroundColor "Yellow"`t"9. Restart RDP services"
- write-host -ForegroundColor 'Green' `t""`t
- write-host -ForegroundColor 'Green' `t"**` Change configuration"`t
- write-host -ForegroundColor 'Green' ------------------------------------
- write-host -ForegroundColor 'Yellow'`t"10. Start sconfig"
- write-host -ForegroundColor 'Yellow'`t"11. Disable or enable firewall"
- write-host -ForegroundColor 'Yellow'`t"12. Enable remote powershell"
- write-host -ForegroundColor 'Green' `t""`t
- write-host -ForegroundColor 'Green' `t"***`Install Windows roles and sysinfo"`t
- write-host -ForegroundColor 'Green' -------------------------------------
- write-host -ForegroundColor "Yellow"`t"13. Install or remove Server Role"
- write-host -ForegroundColor "Yellow"`t"14. Show running services"
- write-host -ForegroundColor 'Yellow'`t"15. System services information"
- write-host -ForegroundColor "Yellow"`t"16. Show System information with expert"
- write-host -ForegroundColor "Yellow"`t"17. Fix Sharepoint IIS problem"
- write-host -ForegroundColor "Yellow"`t"18. Run SFC /scannow"
- write-host -ForegroundColor "Yellow"`t"19. Restore the health with DISM"
- write-host -ForegroundColor "Yellow"`t"20. Show stopped services"
- write-host -ForegroundColor "Yellow"`t"21. Start or stop a service"
- write-host -ForegroundColor "Yellow"`t"22. Boot into Different boot state"
- write-host `t""`t
- write-host -ForegroundColor 'Green' `t"****`Import active directory configuration"`t
- write-host -ForegroundColor 'Green' -------------------------------------
- write-host -ForegroundColor "Yellow"`t"23. Import Users into active directory"
- write-host -ForegroundColor "Yellow"`t"24. Import Groups"
- write-host -ForegroundColor 'Yellow'`t"25. Import Grouppolicy"
- write-host -ForegroundColor "Yellow"`t"26. Import OU structure"
- write-host -ForegroundColor "Yellow"`t"27. Import Folder structure on D drive"
- write-host -ForegroundColor "Yellow"`t"28. Import structure,shares and permissions"
- write-host `t""`t
- write-host -ForegroundColor 'Green' `t"*****`Export active directory configuration"`t
- write-host -ForegroundColor 'Green' -------------------------------------
- write-host -ForegroundColor "Yellow"`t"29. Export Users into CSV File"
- write-host -ForegroundColor "Yellow"`t"30. Export Group"
- write-host -ForegroundColor "Yellow"`t"31. Export GroupPolicy"
- write-host -ForegroundColor "Yellow"`t"32. Export OU structure"
- write-host -ForegroundColor "Yellow"`t"33. Export Folder structure Shares, D drive"
- write-host -ForegroundColor "Yellow"`t"34. Export file structure,shares and permissions"
- [int]$userMenuChoice = Read-Host -Prompt ` "
- Type your option or press enter to exit"
- #excecutes the commands given by the user
- switch ($userMenuChoice) {
- #Ping module
- '1' {
- $Server = Read-Host -Prompt 'hostname'
- $value = Read-Host -Prompt 'function'
- ping $Server $value
- #Ping google
- }
- '2'{
- test-connection 8.8.8.8,8.8.4.4
- }
- #test-netconnnection
- '3'{
- $Server = Read-Host -Prompt 'Hostname'
- Test-Connection $server
- }
- #test-netconection using port
- '4'{
- $Server = Read-Host -Prompt 'Hostname'
- $port = Read-Host -Prompt 'port'
- Test-netconnection $server -port $port
- }
- #Tracert host module
- '5'{
- $Server = Read-Host -Prompt 'Hostname'
- Tracert $server
- }
- #NSlookup on host
- '6'{
- $Server = Read-Host -Prompt 'Hostname'
- NSlookup $server
- }
- #ARP on localhost
- '7'{
- $function1 =o Read-Host -Prompt 'function Example -A,-AB'
- arp $function1
- }
- #Netstat
- '8'{
- $function2 = Read-Host -Prompt 'function Example -A,-AB'
- netstat $function2
- }
- #ipconfig
- '8'{
- $function3 = Read-Host -Prompt 'function Example /all /release /fushdns, /registerdns, ipconfig /allcompartments /all'
- Ipconfig $function3
- }
- #restart-rdp services
- '9'{
- write-host -ForegroundColor Green "Trying to restart RDP services"
- Function Restart-RdpServices {
- param([string]$ComputerName = $env:computerName)
- Get-Service -ComputerName $CompaterName -Name 'Remote Desktop Services UserMode Port Redirector' | Stop-Service -Force -Verbose
- Get-Service -ComputerName $ComputerName -Name 'TermService' | Stop-Service -Force -Verbose
- Get-Service -ComputerName $ComputerName -Name 'TermService' | Start-Service -Verbose
- Get-Service -ComputerName $ComputerName -Name 'Remote Desktop Services UserMode Port Redirector' | Start-Service -Verbose
- }
- write-host -ForegroundColor Green "RDP has been restarted"
- [int]$userMenuChoice = 0
- }
- #Start Sconfig
- '10'{
- write-host -ForegroundColor Green "Launching Sconfig"
- start-process powershell -ArgumentList "-noexit -command sconfig"
- }
- #change Firwall settings
- '11'{
- $on = 'True'
- $off = 'False'
- write-host -ForegroundColor Green "Change Firewalls settings"
- $option = Read-Host -Prompt 'True or False'
- Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled $option
- write-host -ForegroundColor Green "The firewall has changed to your setting to $option"
- }
- #change Remote powershell command
- '12'{
- Enable-PSRemoting -SkipNetworkProfileCheck -Force
- write-host -ForegroundColor Green "Powershell Remoting is now enabled"
- }
- #Start switch 1 for roles
- '13'{
- [int]$userMenuChoice1 = 0
- while ( $userMenuChoice1 -lt 1 -or $userMenuChoice1 -gt 26) {
- write-host `t""`t
- write-host -ForegroundColor 'Green'`t"Install or or Remove windows services"`t
- write-host `t""`t
- write-host -ForegroundColor 'Yellow'`t"1. Install Remote desktop services"
- write-host -ForegroundColor "Yellow"`t"2. DHCP COnfiguruation with options"
- write-host -ForegroundColor "Yellow"`t"3. Install RSAT for windows 10"
- write-host -ForegroundColor "Yellow"`t"4. Install Active directory"
- write-host -ForegroundColor "Yellow"`t"5. Install Hyper-V hypervisor"
- write-host -ForegroundColor "Yellow"`t"6. Install Remote access"
- write-host -ForegroundColor "Yellow"`t"7. Remove windows Defender "
- write-host -ForegroundColor "Yellow"`t"7. Remove SMBV1 for security"
- write-host `t""`t
- [int]$userMenuChoice1 = Read-Host -Prompt ` "
- Type your option or press enter to exit"
- #excecutes the commands given by the user
- switch ($userMenuChoice1)
- {
- #Install Remote desktop services
- '1'{
- write-host -ForegroundColor Green -confirm "RDP server gets installed"
- Add-WindowsFeature –Name RDS-RD-Server –IncludeAllSubFeature -Restart
- }
- #DHCPv
- '2'{
- write-host -ForegroundColor Green "DHCP server gets installed"
- Install-WindowsFeature -Confirm Install-WindowsFeature DHCP -IncludeManagementTools
- $computer = $env:computername
- $dns =Read-Host -Prompt 'DNS name'
- $ipAddress =Read-Host -Prompt 'IPAdress'
- Add-DhcpServerInDC -DnsName $dns -IPAddress $ipAddress
- Get-DhcpServerInDC
- Set-ItemProperty –Path registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\Roles\12 –Name ConfigurationState –Value 2
- $name = Read-Host -Prompt 'Name of your scope'
- $scope = -Prompt 'scope ID'
- $start = -Prompt 'StartRange'
- $end = -Prompt 'EndRange'
- $name = -Prompt 'Name of your scope'
- $subnet = -Prompt 'Enter your subnet'
- $dnsserver = -Prompt 'Enter your subnet'
- Add-DhcpServerv4Scope -name "$name" -StartRange $start -EndRange $end -SubnetMask $subnet -State Active`
- Set-DhcpServerv4OptionValue -OptionID 3 -Value $start -ScopeID $scope -ComputerName $computer$dns`
- Set-DhcpServerv4OptionValue -DnsDomain $dns -DnsServer $dnsserver
- }
- #Install RSAT on win10
- '3'{
- write-host -ForegroundColor Green "RSAT server gets installed"
- $web = Invoke-WebRequest https://www.microsoft.com/en-us/download/confirmation.aspx?id=45520
- $MachineOS= (Get-WmiObject Win32_OperatingSystem).Name
- #Check for Windows Server 2012 R2
- IF($MachineOS -like "*Microsoft Windows Server*") {
- Add-WindowsFeature -Confirm RSAT-AD-PowerShell
- Break}
- IF ($ENV:PROCESSOR_ARCHITECTURE -eq "AMD64"){
- Write-host "x64 Detected" -foregroundcolor yellow
- $Link=(($web.AllElements |where class -eq "multifile-failover-url").innerhtml[0].split(" ")|select-string href).tostring().replace("href=","").trim('"')
- }ELSE{
- Write-host "x86 Detected" -forgroundcolor yellow
- $Link=(($web.AllElements |where class -eq "multifile-failover-url").innerhtml[1].split(" ")|select-string href).tostring().replace("href=","").trim('"')
- }
- $DLPath= ($ENV:USERPROFILE) + "\Downloads\" + ($link.split("/")[8])
- Write-Host "Downloading RSAT MSU file" -foregroundcolor yellow
- Start-BitsTransfer -Source $Link -Destination $DLPath
- $Authenticatefile=Get-AuthenticodeSignature $DLPath
- $WusaArguments = $DLPath + " /quiet"
- if($Authenticatefile.status -ne "valid") {write-host "Can't confirm download, exiting";break}
- Write-host "Installing RSAT for Windows 10 - please wait" -foregroundcolor yellow
- Start-Process -FilePath "C:\Windows\System32\wusa.exe" -ArgumentList $WusaArguments -Wait
- }
- '4'{ # install active directory
- Import Server-Manager
- write-host -ForegroundColor Green "Install active directory"
- install-windowsfeature AD-Domain-Services
- Import-Module ADDSDeployment
- Install-ADDSForest
- }
- '5'{ # install Hyper V
- write-host -ForegroundColor Green "Hyper-V"
- Add-WindowsFeature –Name Hyper-V -IncludeAllSubFeature -IncludeManagementTools
- }
- '6'{ # install Remote access
- Install-WindowsFeature RemoteAccess -IncludeManagementTools
- }
- '7' {# install Remote access
- write-host -ForegroundColor Green -confirm "Install Remote access VPN"
- Install-WindowsFeature RemoteAccess -IncludeManagementTools -confirm
- }
- '8'{ #remove windows defender
- Remove-WindowsFeature Windows-Defender, Windows-Defender-GUI
- }
- '9'{ # Remove SMBV1
- Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol #Remove SMBv1 Client Support
- }
- '10'{ #Install windows backup
- Add-WindowsFeature Windows-Server-Backup
- }
- '11'{
- }
- }
- }
- }
- '14'{
- write-host -ForegroundColor Green "Running processes are getting loaded. Press enter"
- while(1) {ps | sort -desc cpu | select -first 30; sleep -seconds 60; cls;
- write-host "Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName";
- write-host "------- ------ ----- ----- ----- ------ -- -----------"}
- }
- #Start Services.msc
- '15'{
- write-host -ForegroundColor Green "System services are getting loaded......."
- service
- Get-WmiObject win32_service | Format-Table -Property Exit,CodeName,ProcessId,StartMode,State,Status |
- where { $_.Caption -notmatch "Windows" -and $_.PathName -notmatch "Windows" -and $_.PathName -notmatch "policyhost.exe" }
- `
- (sleep -seconds 2)}
- #get computer information
- '16'{
- write-host -ForegroundColor Green -confirm "Gathering system information"
- function Get-ComputerInformation {
- [cmdletbinding()]
- param(
- [Parameter()]
- [string]
- $computerName
- )
- if (!$computerName) {
- $osVer = Get-CimInstance Win32_OperatingSystem | Select-Object Caption | ForEach-Object { $_.Caption }
- $installDate = Get-CimInstance Win32_OperatingSystem | Select-Object InstallDate | ForEach-Object { $_.InstallDate }
- $servicePackVer = Get-CimInstance Win32_OperatingSystem | Select-Object ServicePackMajorVersion | ForEach-Object { $_.ServicePackMajorVersion }
- $osArch = Get-CimInstance Win32_OperatingSystem | Select-Object OSArchitecture | ForEach-Object { $_.OSArchitecture }
- $bootDevice = Get-CimInstance Win32_OperatingSystem | Select-Object BootDevice | ForEach-Object { $_.BootDevice }
- $buildNumber = Get-CimInstance Win32_OperatingSystem | Select-Object BuildNumber | ForEach-Object { $_.BuildNumber }
- $osName = Get-CimInstance Win32_OperatingSystem | Select-Object CSName | ForEach-Object { $_.CSName }
- $hostName = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .
- } else {
- }
- $reportObject = [PSCustomObject]@{
- 'OS Version' = $osVer
- 'Install Date' = $installDate
- 'Service Pack Version' = $servicePackVer
- 'OS Architecture' = $osArch
- 'Boot Device' = $bootDevice
- 'Build Number' = $buildNumber
- 'Host Name' = $hostName
- }
- return $reportObject
- }
- $compInfo = Get-ComputerInformation
- $compInfo | Format-List
- Write-Host `n"Detailed Networking Information:"`n
- Write-Host ($compInfo.'Host Name' | Out-String)
- $reportPath = 'C:\reports'
- if (test-path $reportPath)
- {
- Write-Host "Folder found!"
- }
- else
- {
- Write-Host "Folder NOT FOUND!"
- write-host "Folder has been created"
- New-Item -ItemType directory -Path $reportPath
- }
- $compInfo | Export-CSV -Delimiter ";" "$reportPath\system report.csv" -NoTypeInformation -Encoding UTF8
- }
- #fix issue on Share Point IIS
- '17'{
- write-host -ForegroundColor Green "applying hot fix for Sharepoint"
- Copy-Item -Path "$($ENV:SystemRoot)\System32\ServerManager.exe" `
- -Destination "$($ENV:SystemRoot)\System32\ServerManagerCmd.exe" -Force
- Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45
- Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer, `
- Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing, `
- Web-Http-Errors,Web-App-Dev,Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext, `
- Web-ISAPI-Filter,Web-Health,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor, `
- Web-Http-Tracing,Web-Security,Web-Basic-Auth,Web-Windows-Auth,Web-Filtering, `
- Web-Digest-Auth,Web-Performance,Web-Stat-Compression,Web-Dyn-Compression, `
- Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server, `
- AS-Web-Support,AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation, `
- AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,WAS-Process-Model, `
- WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation, `
- Server-Media-Foundation,Xps-Viewer
- }
- #System file Recovery
- '18'{
- write-host -ForegroundColor Green "Restore system health"
- SFC /SCANNOW
- }
- #Powershell system recovery
- '19'{
- write-host -ForegroundColor Green "Restore system health"
- DISM /ONLINE /CLEANUP-IMAGE /RESTOREHEALTH
- }
- #show stopped services on localhost
- '20'{ Get-WmiObject -Class Win32_Service | Select-Object Name,State,StartMode | Where-Object {$_.State -ne "Running" -and $_.StartMode -eq "Auto" } | Format-Table -Property Name,State,StartMode
- }
- '21'{
- #Enable or Disable processes
- $choice = Read-Host -Prompt 'Start,Stop,Restart'
- $Servicename = Read-Host -Prompt 'Service name'
- If ( $choice -eq '') {write-host -ForegroundColor "Red" "Invalid request"}
- If ( $choice -eq 'Start') {
- Get-Service -Name $Servicename | start-service -Verbose
- }
- If ( $choice -eq 'Stop') {
- Get-Service -Name $Servicename | stop-service -Force -Verbose
- }
- If ( $choice -eq 'Restart') {
- Get-Service -Name $Servicename | stop-service -Force -Verbose
- Get-Service -Name $Servicename | start-service -Verbose
- write-host -ForegroundColor Green -confirm "$service has been $choice"
- }
- }
- '22'{
- #write the options on powershell screen and start of switch 2
- [int]$userMenuChoice2 = 0
- while ( $userMenuChoice2 -lt 1 -or $userMenuChoice2 -gt 26) {
- write-host `t""`t
- write-host -ForegroundColor 'Green'`t"Change Boot"`t
- write-host `t""`t
- write-host -ForegroundColor 'Yellow'`t"1. BCDEdit /bootdebug"
- write-host -ForegroundColor "Yellow"`t"2. BCDEdit /dbgsettings"
- write-host -ForegroundColor "Yellow"`t"3. BCDEdit /debug"
- write-host -ForegroundColor "Yellow"`t"4. BCDEdit /deletevalue"
- write-host -ForegroundColor "Yellow"`t"5. BCDEdit /emssettings"
- write-host -ForegroundColor "Yellow"`t"6. BCDEdit /set"
- write-host -ForegroundColor "Yellow"`t"7. BCDEdit /set safeboot "
- write-host -ForegroundColor "Yellow"`t"7. BCDEdit /DSRM recovery mode "
- write-host `t""`t
- #switch number 2 option menu with switching
- [int]$userMenuChoice2 = Read-Host -Prompt ` "
- Type your option or press enter to exit"
- #excecutes the commands given by the user
- switch ($userMenuChoice2)
- {
- '1' {
- BCDEdit /bootdebug
- restart-computer -Confirm
- }
- '2' {
- BCDEdit /dbgsettings
- restart-computer -Confirm
- }
- '3' {
- BCDEdit /debug
- restart-computer -Confirm
- }
- '4' {
- BCDEdit /deletevalue
- restart-computer -Confirm
- }
- '5' {
- BCDEdit /emssettings
- restart-computer -Confirm
- }
- '6' {
- BCDEdit /set
- restart-computer -Confirm
- }
- '7' {
- BCDEdit /set safeboot
- restart-computer -Confirm
- }
- '8' {
- BCDEdit /set safeboot dsrepair
- restart-computer -Confirm
- }
- #end switch 2
- }
- }
- }
- '23'{
- #create active directory users
- $locationuser = Read-Host -Prompt 'Put the name of file here'
- $users = Import-Csv -delimiter ";" -path $locationuser.csv
- foreach($user in $users)
- {
- $fullname = $user.firstname + " " + $User.middlename + $user.lastname
- $firstname = $user.firstname
- $lastname = $user.lastname
- $domain = "@mocati.eu"
- $upn = $user.firstname + $User.middlename + $user.lastname + $domain
- $ou = $user.ou
- $password = "Welkom01!"
- $setpassword = ConvertTo-SecureString $password -AsPlainText -Force
- $Usermiddlename = $User.middlename
- $first,$last = ($firstname.toUpper()).Split(" ")
- $letter = $first[0]
- $username = $letter + $User.middlename + $lastname
- New-ADUser -Name $username -displayname $fullname `
- -GivenName $firstname -surname $lastname `
- -SamAccountName $lastname `
- -UserPrincipalName $upn `
- -AccountPassword $setpassword -Enabled $true -PassThru `
- -ChangePasswordAtLogon $false
- }
- }
- '24'{
- $locatiegroepen = Read-Host -Prompt 'Put the name of file here'
- $csv = Import-Csv -delimiter ";" -Path "C:\scripts\$locatiegroepen.csv"
- ForEach ($item In $csv)
- {
- $create_group = New-ADGroup -Name $item.GroupName -GroupCategory $item.GroupCategory -groupScope $item.GroupScope
- Write-Host -ForegroundColor Green "Group $($item.GroupName) created!"
- }
- }
- '25'{
- write-host "feature not here yet"
- }
- '26'{
- #OU script
- $oulocation = Read-Host -Prompt 'Put the name of file here'
- $listOU=Import-Csv -delimiter ";" -Path "C:\scripts\$oulocation.csv"
- ForEach($OU in $listOU){
- try{
- #Get Name and Path from the source file
- $OUName = $OU.Name
- $OUPath = $OU.Path
- #Display the name and path of the new OU
- Write-Host -Foregroundcolor Yellow $OUName $OUPath
- #Create OU
- New-ADOrganizationalUnit -Name "$OUName" -Path "$OUPath"
- #Display confirmation
- Write-Host -ForegroundColor Green "OU $OUName created"
- }catch{
- Write-Host $error[0].Exception.Message
- }
- }-Path "$alleOU" -ProtectedFromAccidentalDeletion $false
- }
- '27'{
- $locationfolder = Read-Host -Prompt 'Put the location C:\*\something'
- $csvfilelocation = Read-Host -Prompt 'Put the location of CSV file C:\*\something.csv'
- Set-Location "$locationfolder"
- $Folders = Import-Csv $csvfilelocation
- ForEach ($Folder in $Folders) {
- New-Item $Folder.Name -type directory
- }
- }
- '28'{
- #needs changes
- write-host "feature not programmed yet"
- }
- '29'{ Get-ADUser -Filter 'Company -like "Alpha*"' -Properties * | Select -Property EmailAddress,GivenName,Surname,DisplayName,Title,Department,Office,OfficePhone,MobilePhone,Fax,StreetAddress,City,State,PostalCode,Country | Export-CSV "C:\\ADusers.csv" -NoTypeInformation -Encoding UTF8
- }
- '30'{ #// Start of script
- #// Get year and month for csv export file
- $DateTime = Get-Date -f "yyyy-MM"
- #// Set CSV file name
- $CSVFile = "C:\AD_Groups"+$DateTime+".csv"
- #// Create emy array for CSV data
- $CSVOutput = @()
- #// Get all AD groups in the domain
- $ADGroups = Get-ADGroup -Filter *
- #// Set progress bar variables
- $i=0
- $tot = $ADGroups.count
- foreach ($ADGroup in $ADGroups) {
- #// Set up progress bar
- $i++
- $status = "{0:N0}" -f ($i / $tot * 100)
- Write-Progress -Activity "Exporting AD Groups" -status "Processing Group $i of $tot : $status% Completed" -PercentComplete ($i / $tot * 100)
- #// Ensure Members variable is empty
- $Members = ""
- #// Get group members which are also groups and add to string
- $MembersArr = Get-ADGroup -filter {Name -eq $ADGroup.Name} | Get-ADGroupMember | select Name
- if ($MembersArr) {
- foreach ($Member in $MembersArr) {
- $Members = $Members + "," + $Member.Name
- }
- $Members = $Members.Substring(1,($Members.Length) -1)
- }
- #// Set up hash table and add values
- $HashTab = $NULL
- $HashTab = [ordered]@{
- "Name" = $ADGroup.Name
- "Category" = $ADGroup.GroupCategory
- "Scope" = $ADGroup.GroupScope
- "Members" = $Members
- }
- #// Add hash table to CSV data array
- $CSVOutput += New-Object PSObject -Property $HashTab
- }
- #// Export to CSV files
- $CSVOutput | Sort-Object Name | Export-Csv $CSVFile -NoTypeInformation
- #// End of script
- }
- '31'{
- Import-Module ActiveDirectory
- Import-Module GroupPolicy
- $dc = Get-ADDomainController -Discover -Service PrimaryDC
- Get-GPOReport -All -Domain enterprise.com -Server $dc -ReportType HTML -Path C:\Temp\GPOReportsAll.html
- }
- '32'{
- import-module activedirectory
- Get-ADOrganizationalUnit -filter * | select Name,DistinguishedName | Export-csv -path C:\ADOrganizationalUnitsexport.csv -NoTypeInformation
- }
- '33'{
- $FolderPath = dir -Directory -Path "\\fs1\Shared" -Recurse -Force
- $Report = @()
- Foreach ($Folder in $FolderPath) {
- $Acl = Get-Acl -Path $Folder.FullName
- foreach ($Access in $acl.Access)
- {
- $Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
- Group or
- User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
- $Report += New-Object -TypeName PSObject -Property $Properties
- }
- }
- $Report | Export-Csv -path "C:\data\FolderPermissions.csv"
- }
- '34'{
- $FolderPath = dir -Directory -Path "\\fs1\Shared" -Recurse -Force
- $Report = @()
- Foreach ($Folder in $FolderPath) {
- $Acl = Get-Acl -Path $Folder.FullName
- foreach ($Access in $acl.Access)
- {
- $Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
- Group or
- User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
- $Report += New-Object -TypeName PSObject -Property $Properties
- }
- }
- $Report | Export-Csv -path "C:\data\FolderPermissions.csv"
- }
- #end primary switch {}
- }
- }
- }
- while ($userMenuChoice -ne 5 )
- #extra option Clear-Item WSMan:\localhost\Client\TrustedHosts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement