Powershell script for creating copy of GPOs

jay k 21 Reputation points
2021-06-23T07:39:17.733+00:00

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

Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
{count} votes

2 answers

Sort by: Most helpful
  1. Leon Laude 86,026 Reputation points
    2021-06-23T08:42:50.127+00:00

    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,
    Leon


  2. Anonymous
    2021-06-24T01:44:37.117+00:00

    Hi,

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.