Backup GPOs basing on GPO DisplayName

$invalidChars = ‘:\\/’ + [RegEx]::Escape(-join [IO.Path]::InvalidPathChars)

$backupDir = ‘C:\temp\backup’
Get-GPO -All -Domain <DOmain Name>| ForEach-Object {
$name = $_.DisplayName -replace “[$invalidChars]”, ‘_’
$gpoDir = Join-Path $backupDir -ChildPath $name
New-Item $gpoDir -Type Directory | Out-Null
Backup-GPO -Domain <DOmain Name> -Guid $_.Id -Path $gpoDir
}

Be the first to comment

Leave a Reply

Your email address will not be published.


*