Windows Server 2008 & 2012 Export & Import GPO Using Powershell

 

There may be times when it is useful to use an existing Group Policy Object (GPO) as a template for a GPO on another server, or perhaps you just need to perform a GPO backup and restore. Here is how to export and import GPOs from the command line.

 

Starting the Group Policy Cmdlet in Powershell

Firstly, from the command line start powershell and import the Group Policy Cmdlet:

powershell

import-module grouppolicy

 

Exporting a GPO

Check that the backup directory you wish to use exists. If not, create it.

Powershell command:

Backup-GPO -Name -Path

Example: to backup a GPO called “Example GPO” to the directory “C:\GPOBackup”

Backup-GPO -Name "Example GPO" -Path "C:\GPOBackup"

 

Importing a GPO

Keeping the same GPO Name

Powershell command:

Import-GPO -BackupGPOName -CreateIfNeeded -Path

Example: to import a GPO called “Example GPO” from the directory “C:\GPOBackup”

Import-GPO -BackupGPOName "Example GPO" -CreateIfNeeded -Path "C:\GPOBackup"

Renaming the GPO

Powershell command:

Import-GPO -BackupGPOName -TargetName -CreateIfNeeded -Path

Example: to import a GPO called “Example GPO”, renaming it to “New GPO”, from the directory “C:\GPOBackup”

Import-GPO -BackupGPOName "Example GPO" -TargetName "New GPO" -CreateIfNeeded -Path "C:\GPOBackup"

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s