Copy all GPOs from one forest to another

September 20, 2016

tags:
no comments

Hey,

The following presents a PS Script that Copy all GPOs from one forest to another,

  1. Backed up all GPOs in one domain using Backup-GPO
  2. Imported them to the other forest by using Import-GPO

Load the following Modules before run PS Script:

Import-Module ActiveDirectory           
Import-Module GroupPolicy 

 
$sPath = “X:\GPOFOLDER”
$list = get-childitem $sPath | Select name
foreach ($item in $list) {
    $fXML = $sPath + “\” + $item.Name + “\gpreport.xml”
    $XMLData = [XML](get-content $fXML)
    $GPOName = $XMLData.GPO.Name
    import-gpo -BackupId $item.Name -TargetName $GPOName -path $sPath -CreateIfNeeded
}

 

 

signtureblog

 

 

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*