Skip to content

Instantly share code, notes, and snippets.

@bizouarn
Created June 20, 2024 10:20
Show Gist options
  • Save bizouarn/da31c00605dbe58548f382fc6c0417a2 to your computer and use it in GitHub Desktop.
Save bizouarn/da31c00605dbe58548f382fc6c0417a2 to your computer and use it in GitHub Desktop.
Import-Module GroupPolicy
$BackupPath = "C:\temp\GPOBackup"
if (Test-Path $BackupPath) {
Remove-Item -Path $BackupPath\* -Recurse -Force
} else {
New-Item -ItemType Directory -Path $BackupPath
}
Backup-GPO -All -Path $BackupPath
# Export all GPO to CSV
$ListGPO = Get-GPO -all | Select-Object DisplayName
$ListGPO | Export-Csv -Path "$BackupPath\ListGPO.csv" -NoTypeInformation -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment