How can I get a list of all the OUs and sub-OU's in AD

amaru96
amaru96 used Ask the Experts™
on
Hi guys, how can I get a list of all the OUs and sub-OU's in AD and be able to get that information into excel?

Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2013
Commented:
I really like adfind for this sort of thing  http://www.joeware.net/freetools/tools/adfind/index.htm

Joe has a shortcut  

adfind -sc oudmp

or

adfind -default -f objectcategory=organizationalunit name -csv > c:\OUs.csv

Thanks

Mike

Author

Commented:
Hi, that works pretty well, I particularly like the first dump "adfind -sc oudmp", however it brings back a result for all the OU's across ALL the domains. Is there a way to specifiy which domain to search in?
Top Expert 2013

Commented:
Suppose your domain was    domain.com

adfind -b "dc=domain,dc=com" -sc oudmp

thanks

Mike

Author

Commented:
Thanks a lot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial