Home » General » Backup GPOs basing on GPO DisplayName

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
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Name *
Email *
Website