listing information from WIN2K3 ADUC

nav2567
nav2567 used Ask the Experts™
on
I have a OU which has a lot of sub-OUs.  How do I run a report to list out all the user object as well as listing the OU location (canonical name)?  

Thanks in advance.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Henrik JohanssonSystems engineer
Top Expert 2008

Commented:
Use the dsquery or csvde command line tools to generate a tab/comma separated list with any wanted attribute of the user and import the output file into Excel or other application

dsquery * -filter "(&(objectclass=user)(objectcategory=person))" -attr dn samaccountname sn givenname
dsquery * -filter "(&(objectclass=user)(objectcategory=person))" -attr dn samaccountname sn givenname > output.txt

csvde -f output.csv -r "(&(objectclass=user)(objectcategory=person))" -l samaccountname,sn,givenname

Author

Commented:
do I need to specify the name of the OU which I want to run the query?  I do not want to touch the other OUs in the root of my domain.
Thanks.
Systems engineer
Top Expert 2008
Commented:
Yes, I forgot the optional OU-parameter where the path is entered in DN-syntax from bottom to top.
I also see I forgot the limit parameter for dsquery command resulting by default to only return first 100 records. Set it to 0 to be unlimited.

dsquery * -limit 0 -filter "(&(objectclass=user)(objectcategory=person))" "OU=childOU,OU=parentOU,DC=domainname,DC=local" -attr dn samaccountname sn givenname

csvde -f output.csv -r "(&(objectclass=user)(objectcategory=person))" -d "OU=childOU,OU=parentOU,DC=domainname,DC=local" -l samaccountname,sn,givenname

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