-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathExport-GPOSettings.ps1
17 lines (12 loc) · 972 Bytes
/
Export-GPOSettings.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$GPOSettingsFolderPath = "D:\Scripts\AD-ExportGPOSettings\"
$GPOSettingsResultFolderPath = $GPOSettingsFolderPath + "\Results\"
cd $GPOSettingsFolderPath
Get-GPO -All | % {$_.GenerateReport('html') | Out-File "$($_.DisplayName).htm"}
Get-GPO -All | % {$_.GenerateReport('xml') | Out-File "$($_.DisplayName).xml"}
Get-ChildItem *.xml | ForEach-Object { $NewName = $_.BaseName + "_" + $_.LastWriteTime.toString("yyyy.MM.dd.HH.mm") + ".xml" ; Rename-Item -Path $_.FullName -newname $NewName }
Get-ChildItem *.htm | ForEach-Object { $NewName = $_.BaseName + "_" + $_.LastWriteTime.toString("yyyy.MM.dd.HH.mm") + ".htm" ; Rename-Item -Path $_.FullName -newname $NewName }
If (!(Test-Path -Path $GPOSettingsResultFolderPath)) {
New-Item -ItemType "Directory" -Path $GPOSettingsResultFolderPath -Force
}
Get-ChildItem *.xml -Recurse | Move-Item -Destination $GPOSettingsResultFolderPath
Get-ChildItem *.htm -Recurse | Move-Item -Destination $GPOSettingsResultFolderPath