On your source domain in Group Policy Management Console, select the
policy(ies) that you want to transfer. Copy them to a shared location
which both domains can see--or use a thumb drive to copy to your
destination DC
In your destination domain in Group Policy Management Console.
"the trick is, that you need to create a empty GPO first. Then you can
right click on the empty GPO and select import, which allows you to import
the GPO settings. Browse to the folde where the settings are located."
https://social.technet.microsoft.com/Forums/en-US/a3b6cb52-0f7f-40e1-a311-cfa99b34a2ef/gpos-and-importingrestoring-from-a-backup?forum=winserverGP
$Server="<server>"
$domain="FQDN"
$path="c:\temp\gpotest2"
# Get current GPO information
$GPOInfo = Get-GPO -All -Domain $domain -Server $Server
#Create a date-based folder to save backup of group policies
$Date = Get-Date -UFormat "%Y-%m-%d"
$UpdatedPath = "$path\$date"
New-item $UpdatedPath -ItemType directory | Out-Null
Write-Host "GPO's will be backed up to $UpdatedPath" -backgroundcolor white -foregroundColor red
} #end of begin block
process {
ForEach ($GPO in $GPOInfo) {
Write-Host "Backing up GPO named: " -foregroundColor Green -nonewline
Write-Host $GPO.Displayname -foregroundColor White
#Assign temp variables for various parts of GPO data
$BackupInfo = Backup-GPO -Name $GPO.DisplayName -Domain $Domain -path $UpdatedPath -Server $Server
$GpoBackupID = $BackupInfo.ID.Guid
$GpoGuid = $BackupInfo.GPOID.Guid
$GpoName = $BackupInfo.DisplayName
$CurrentFolderName = $UpdatedPath + "\" + "{"+ $GpoBackupID + "}"
$NewFolderName = $UpdatedPath + "\" + $GPOName + "___" + "{"+ $GpoBackupID + "}"
$ConsoleOutput = $GPOName + "___" + "{"+ $GpoBackupID + "}"
Write-Host $CurrentFolderName
#Rename the newly created GPO backup subfolder from its GPO ID to the GPO Displayname + GUID
#rename-item $CurrentFolderName -newname $NewFolderName
} #End ForEach loop
} #End of process block
$files = $UpdatedPath
$target = "C:\s3_ch.disasterrecovery-recipes-2022\GPO_Backup"
Get-ChildItem -Path "$files\*\*" -Directory |
Foreach-Object {
$month = $_.Parent.Name
$newname = $_.name.ToLower() -replace(" ","")
sz a -t7z "$target\$month\$newname" $_.FullName
if(Test-Path "$target\$month\$newname") {
Remove-Item -Path $_.FullName -Force -Recurse -Confirm:$false
}
If (!(Get-ChildItem -path $_.Parent.FullName -Directory)) { # all sub-folders archived
Remove-Item -Path $_.Parent.FullName -Force
Write-Host ("directory removed: {0}" -f $_.Parent.FullName)
}
}