We have some consultants coming in to assist with a MetaDirectory project that is going on at my current client and they asked me for some information--they wanted some documentation of our OU structure. I figured I already had something in place to document something as simple as this but, alas, I did not. So, I googled around for a freeware utility or script and I couldn't really find anything. I think DSRazor and a couple of other commercial tools would do it but I was disappointed and surprised that I didn't find anything free.
So, should I write the code from scratch or steal from wherever I can?? Hmmm...easy decision there. I remembered working with the scripts included with the GPMC (Group Policy Management Console) and thought there might be something in there I could use. Jackpot!
"ListSOMPolicyTree.wsf" does what I need (and a bit more--I don't care about GPOs right now, just OUs). So, I just made a copy of the file and commented out lines 72-88 and 204-240. I also updated the text that is displayed via line 66 to ""=== OU structure for domain " instead of ""=== GPO Links for domain ".
Presto magic, we have a nice looking export of the OU structure for the domain.
=== OU structure for domain ds.ad.ssmhc.com ===
DC=ds
OU=Accounts
OU=Admin
OU=Consultants
OU=Domain Controllers
OU=EMC Celerra
OU=Computers
OU=Management Workstations
OU=Interfaces
OU=Policy Free OU
OU=GE
OU=INW
OU=SFHBI
OU=MLCL Computers
OU=MLCL Acquisition Workstations
OU=MLCL Review Workstations
OU=MLCL Server
OU=MLCL Software Groups
OU=MLCL Software Only
OU=MLCL Users
OU=Servers
OU=Citrix Servers
OU=Citrix Servers - Show Desktop
OU=Citrix Test Servers
OU=IAS Servers
OU=IC Servers
OU=SIS Servers
OU=SIS Test Servers