Search This Blog

Tuesday, April 14, 2009

Copy a Complete OU infrastructure

Somethimes you need to copy a complete OU Structure within a single domain. This can be done by following command:

"FOR /F "Tokens=1 Delims=," %* IN ('DSQUERY OU "OU=%Name OU%,DC=%Domain%,DC=%Prefix%"') DO DSADD OU %*,OU=%Parent OU%,DC=%Domain%,DC=%Prefix%"

Change the %Name OU%, %Parent OU%, %Domain% and %Prefix% with your own parameters.

Example:
"FOR /F "Tokens=1 Delims=," %* IN ('DSQUERY OU "OU=Sales,DC=Contoso,DC=Com"') DO DSADD OU %*,OU=Offshore,DC=Contoso,DC=Com"

No comments:

Post a Comment