Powershell script for creating copy of GPOs

jay k 21 Reputation points

Team, could you please help with the script to copy the existing GPOs and create a copy of the GPO with PowerShell script for creating copy of the multiple GPOs for testing

A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,829 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,403 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Leon Laude 85,676 Reputation points

    Hi @jay k ,

    You can accomplish this by using the Copy-GPO PowerShell cmdlet, here's a couple of examples on how to copy a Group Policy with PowerShell:

    Copy one GPO

    Copy-GPO -SourceName "TestGpo1" -SourceDomain "test.contoso.com" TargetName "TestGpo1" -TargetDomain "sales.contoso.com"  

    Copy all GPOs

    Get-GPO -All -Domain "sales1.contoso.com" | ForEach-Object {$_ | Copy-GPO -TargetName ($_.DisplayName) -TargetDomain "sales2.contoso.com" -CopyAcl -MigrationTable "C:\Temp\tables\MigrationTable.migtable"}  


    If the reply was helpful please don't forget to upvote and/or accept as answer, thank you!

    Best regards,

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 31,016 Reputation points Microsoft Vendor


    You can link the GPO to a specified OU using the New-GPLink cmdlet.

    $sourceGPO = "TestGPO"  
    $targetGPO = "test_productionGPOname"  
    $ou = "OU=test, DC=contoso, DC=com"  
    Copy-GPO -SourceName $sourceGPO -TargetName $targetGPO  
    New-GPlink -Name $targetGPO -target $ou -LinkEnabled Yes  

    Best Regards,
    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments