Export and import (GPO)

2 September 2021 0 By angelusadeuszabulus

There are two ways to export and import GPOs: you can use the Group Policy Management Console (GPMC) or you can use PowerShell.

GPMC

Backup

  • Open GPMC
  • Go to the Group Policy Object container
  • Right click on the GPO in question and select Save.
  • Follow the dialogs that appear and save the GPO wherever you want on the computer.

Note that you need to go down to the Group Policy Object container. Right-clicking on the links to GPOs from any organizational unit will not give you the correct menu.

The folder where you save the GPOs contains subfolders that contain the GPO files and settings. Subfolders are named after GUIDs that uniquely identify the instance of the backup.

If you make another backup of the same GPO in the same folder, the created subfolder will have a different GUID. In these subfolders, you can double-click a file called bkupInfo.xml to see the details of the GPO that was backed up.

Restore

Open GPMC

  • Right click on the Group Policy Object container and select Manage Backups.
  • In the dialog box that appears, set the path to the folder containing the backed up GPOs, and then select the GPO you want to restore.

Note that you can only restore GPOs to the same domain from  which they were backed up, no domain with the same name, but the same domain .

Import

To work around this problem, you can  import  GPOs. To do this, go down to the Group Policy Object container:

  • Create a new GPO
  • Right click on the GPO and select Import Configurations.
  • Follow the dialog box that appears to indicate the path of the folder containing your saved GPOs
  • Select the desired GPO and import.

The difference between import and restore is that the former does not preserve security settings and does not restore GPO links.

PowerShell

  • You need to import the Group Policy module

  • To display the list of GPOs type the following command:

  • Results

  • To back up a GPO type the following command:

  • Results

  • To restore a GPO type the following command:

  • Results

  • To import a GPO, first create a GPO with the following command:

  • Results

  • Once the GPO is created, Import a GPO with the following command:

  • Results

  • To delete a GPO type the following command:

Bonus

I give you a little bonus, generally during a domain controller migration with a change of drill bit, we want to recover the GPOs present on the source domain without creating them again, unfortunately the ADMT tool does not allow this to be done.

I am using the following script which mirrors the combination of the commands seen above in a loop, it will allow you to:

  • Back up all GPOs on the source domain
  • Export the full list of source domain GPOs
  • Creates Group Policy Objects from CSV
  • Import settings from GPOs

Note:

The copy of GPOs / CSV files will have to be done manually from the source domain to the destination domain.

Views: 12981