Link to home
Start Free TrialLog in
Avatar of Colchester_Institute
Colchester_InstituteFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Clone (Copy) OU Structure

Hi THere

I'm looking at cloning our OU structure in AD.

Basically I need to create a new Top Level OU and then winthin that copy OUS from a existing OU to that one.

Example:
Current OU is Client Computers
Within that are some sub OUs
and with them more sub OUs

I wish to create a new OU called NEW Client Computers and then have the same structure that is within Client Computers

I've found the following site that explains it better http://globalknowledgeblog.com/technology/microsoft/cloning-parallel-ou-hierarchy/

However when i try to use the command dsquery ou | select-string i get an error saying its "not recognized as an Internal Or external command"

Is there another way i can do this using powershell? or can some tell me how to get the dsquery command to work

Many thakns
Avatar of d3ath5tar
d3ath5tar
Flag of United Kingdom of Great Britain and Northern Ireland image

are the ds* tools installed on your os? the solution of global knowledge is pretty spot on!
Avatar of Colchester_Institute

ASKER

I can do a dsquery no problems so i assume so?
And your running this in a powershell or powershellISE window? Since you can get to dsquery that points at the select-string as the next logical step which would not be accessible from a standard cmd dos window...

Install the support tools for Windows Server 2003.

Windows Server 2003 Service Pack 2 32-bit Support Tools
The referenced web page uses a compination of traditional AD command line tools (dsquery) and PowerShell cmdlets (select-string). So you have to run these expressions in PowerShell window.
But if you can use Quest's Active Directory cmdlets, I can show you a complete, PowerShell-only solution.
D3ath5tar was right  as I was trying to run it in a dos window.not powershell

Now when i run the command though I get told the limit of 100 has been reached (I'm not sure where i should put the -limit command)

and also i'm getting told that DSfailed directory object not found?
soostibi powershell would be better if you have a solution for that
in the dsquery ou change it to

dsquery ou -1000 | sele..........

my bad.... -limit 1000
object not found says your string doesn't match....
string not matching - would that be because they are sub OUs? of the OU i've used in the select-string?
also am i right in thinking this will only copy the OUS? not the objects within the OUs?
correct
Is that correct to both queries i made

Sorry, missed your first reply!

The string only needs to be the name of the root OU you want to copy from.... nested ou's don't need to be listed. It picks those up by virtue of their location....

You are correct in thinking that only OU objects will be replicated.
ASKER CERTIFIED SOLUTION
Avatar of soostibi
soostibi
Flag of Hungary image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@d3ath5star - hmmm thats strange then as I dont understand why i get the object error?

@soostibi - I'll give it a try and see how i get on.  Am i right i need to have the target root already in place?
Yes, the target should be already created in this version.
@ Soostibi ok cheers
Solution was spot on and I now have the script for future uses