In more than one project, I have run across the desire to export GPOs that I have created and re-import them. While this can be easily accomplished by customers who have access to AGPM by following MSFT’s Guide, this is not always the case. The following is an alternative way that will work with any environment as it is PowerShell based.
GPO Export
Start PowerShell and Import the Group Policy module:
import-module grouppolicy
Run the Following Command to the Directory you want to export Powershell command:
Backup-GPO -Name "GPOName" -Path "ExportPath"
I.E. Exporting a GPO called “Pablo GPO” to the directory C:\GPOs
Backup-GPO -Name "Pablo GPO" -Path "C:\GPOs"
GPO Import
When it coms to the import, it can be easily accomplished by running the following command:
Import-GPO -BackupGPOName <GPOName> -CreateIfNeeded -Path <ImportPath>
I.E. Importing the “Pablo GPO” from the directory C:\GPOs
Import-GPO -BackupGPOName "Pablo GPO" -CreateIfNeeded -Path "C:\GPOs"
Additionally, you can use the -TargetName flag to change the name of the GPO when importing it.
I.E. Importing the “Pablo GPO” from the directory C:\GPOs and renaming it to “Corporate GPO”
Import-GPO -BackupGPOName "Pablo GPO" -TargetName "Corporate GPO" -CreateIfNeeded -Path "C:\GPOs"