Mirror an OU Structure to a Test Domain

A while back I wrote a couple of scripts for backing up Group Policies and then importing that backup into a test environment. More on those scripts here:

Comprehensive GPO Backup / Import Scripts


Notice the use of 'comprehensive' in the script titles. I chose this word because there were a couple of things the scripts didn't do. One of those things was to mirror the OU structure of the source domain to the target domain. This is no longer an issue...

Let me introduce a couple of companion scripts to ensure we have a matching OU structure in the test environment:

Dump AD OU Structure Script

Mirror AD OU Structure Script


The names give the script functions away:

  • the first script dumps the OU name, OU DN, OU parent DN and domain DN to an XML file
  • the second script reconstructs the OU structure in a target test domain


No OUs were hurt in the production of this post...

Comments (2)

  1. Anonymous says:

    With Windows Server 2012 R2 we get a new, ‘bad-boy’ constructed attribute…

  2. DavidECook says:

    These scripts worked to perfection for me. Many thanks for sharing your knowledge! I was even able to use your Dump AD User script to dump AD Groups. (However, I was not able to modify the Mirror AD User script to mirror the groups I exported to XML).
    Any chance of us seeing a Dump/Mirror AD Group script?!?!

Skip to main content