Backup and Restore Group Policy Objects

In this post, We will see how to backup and restore Group Policy objects and to Export and import the GPO settings to other domains.

Backup Group Policy Objects

Suppose we have created couple of GPO for Windows 10 clients with the name Win10_GPO

#Search All GPO with name starting with Win10
$newGPOs = Get-GPO -All | where {$_.DisplayName -like "Win10*"} | Select DisplayName
#Backup All the GPO
$newGPOs | % { 
    #Backup GPO to a location
    $output = Backup-GPO -Name $_.DisplayName -Path D:\OU 
    #Write GPO file GUID and name to a CSV file
    $output | select DisplayName, Id | export-csv D:\OU\GPO_OBJ.csv -Append

We are exporting the GPO name and file GUID to a CSV, which is used while importing GPO

Restore Group Policy Objects

$csvData = import-csv "D:\OU\GPO_OBJ.csv"
foreach($GPOdetails in $csvData) {
    #Importing GPO from location
    Import-GPO -BackupId $GPOdetails.Id -Path D:\OU -TargetName $GPOdetails.DisplayName -CreateIfNeeded

All your GPO is back.

We can use this to create policy in one domain and export to other domains. It saves time.

Thank you for reading my post. Hope this is helpful to you.