-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGet-GPOs.ps1
More file actions
25 lines (23 loc) · 1.02 KB
/
Get-GPOs.ps1
File metadata and controls
25 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
$output_folder = 'C:'
if (Get-Module -ListAvailable -Name ActiveDirectory) {
Write-Host "AD Module exists"
Write-Host "Exporting GPO reports"
} else {
Write-Host "ActiveDirectory PowerShell module does not exist"
Write-Host "This script requires the ActiveDirectory module to function"
Write-Host " "
$user_input = Read-Host -Prompt 'Attempt to install module? (y/n)'
$rsatAD = Get-WindowsFeature | Where {$_.Name -eq "RSAT-AD-Tools"}
if ($user_input.ToLower() -eq "y" -or $user_input.ToLower() -eq "yes"){
Write-Host "Attempting to install module"
Install-WindowsFeature RSAT-AD-PowerShell
} else {
Write-Host "Stopping script. Please move to a machine with the ActiveDirectory module installed or install it manually"
exit
}
}
$domains = (Get-ADForest).domains
foreach ($domain in $domains){
Get-GPOReport -All -Domain $domain -ReportType HTML -Path "$output_folder\$domain.html"
Get-GPOReport -All -Domain $domain -ReportType XML -Path "$output_folder\$domain.xml"
}