Windows Server 2008 and Windows Vista : Copying and Importing GPOs
To efficiently utilize existing GPOs and their settings, you can use the copy and import features within the GPMC and the following scripts. The copy option allows a company to move GPOs efficiently from a test domain to a production domain, without having to manually duplicate the settings from one environment to the other.
1. CopyGPO.wsf
This script copies a GPO from one domain to another. This is ideal for moving GPOs from a test domain to production domain, or any other situation in which two domains need duplicate GPOs. If the GPO contains UNC paths or security principal references, the migration tables must be used to translate them from one domain to another.
Syntax
Usage: CopyGPO.wsf SourceGPO TargetGPO [/SourceDomain:value] [/TargetDomain:value]
[/SourceDC:value] [/TargetDC:value] [/MigrationTable:value] [/CopyACL]
SourceGPO: Name of the source GPO.
TargetGPO: Name of the target GPO.
SourceDomain: DNS name of the source domain.
TargetDomain: DNS name of the target domain.
SourceDC: Domain controller to use in the source domain.
TargetDC: Domain controller to use in the target domain.
MigrationTable: Migration table to use.
CopyACL: Copies the ACL on the GPO.
Example
This script copies the contents of GPO1 from the test.fabrikam.com domain and places the contents into GPO1 located in the production.fabrikam.com domain.
cscript CopyGPO.wsf GPO1 GPO1 /SourceDomain:test.fabrikam.com
/TargetDomain:production.fabrikam.com
2. ImportGPO.wsf
This script imports the settings from a backed-up GPO into an existing (target) GPO. If there is more than one version of the backed-up GPO, the latest is used. If you want to use a version other than the latest backed-up GPO for importing the settings, you must specify the Backup ID in the script. If you do not specify a target GPO, the target will be the name of the GPO backup. If a GPO exists with that name, the script imports the information into the existing GPO. If a GPO does not exist with that name, and you use the CreateIfNeeded switch, the script will create a new GPO in that name. You can use a migration table to handle any UNC paths or security principals must be translated during the import to the existing GPO.
Importing a GPO does not restore delegation information. To restore delegation information for a GPO, use the RestoreGPO.wsf script.
Syntax
Usage: ImportGPO.wsf BackupLocation BackupID [TargetGPO] [/MigrationTable:value]
[/CreateIfNeeded] [/Domain:value]
BackupLocation: File system location where the backup is located.
BackupID: GPO name or backup ID (GUID) of the backup to use.
TargetGPO: Target GPO in which to import settings.
MigrationTable: Optional migration table to use when importing.
CreateIfNeeded: Creates a new GPO if the specified target GPO does not exist.
Domain: DNS name of domain.
Example
This script takes the contents from the GPO with the specified GUID and copies them to a new GPO, named GPO1. The script specifies that the new GPO should be created if it does not already exist.
cscript ImportGPO.wsf \\Server1\gpo-backup {73624CC9-E8F2-4F05-88D2-193FAE8773CE} GPO1
/CreateIfNeeded
3. ImportAllGPO.wsf
This script creates a new GPO for every GPO that you have backed up in the reference backup location. The script uses only the latest version of the GPO from the backup location. The new GPO will maintain the same name as the GPO that you backed up. This script will not account for duplicate GPO names, so if there are existing target GPOs with the same name as those in the backup location, the script will overwrite the existing GPOs with the new GPO you are importing. Any settings you created in the existing GPO will be lost.
Syntax
Usage: ImportAllGPOs.wsf BackupLocation [/MigrationTable:value] [/Domain:value]
BackupLocation: File system location containing the GPO backups.
MigrationTable: Optional Migration table to use when importing.
Domain: DNS name of domain.
Example
This script takes all GPOs that have been archived to the gpo-backup share and imports the settings into existing (or new) GPOs, using the settings in the migration table named MigrationTable1.xml.
cscript ImportAllGPOs.wsf \\Server1\gpo-backup /MigrationTable:"G:\MigrationTable1.xml"