/build/static/layout/Breadcrumb_cap_w.png

DSQUERY to find all computer names in an OU

I am trying to find all the computer names in a specific OU in AD (Server 2008 R2) and print them out to a text file using DSQUERY. Does anyone have the proper syntax? I am running from cmd line as admin and not having much luck?



2 Comments   [ + ] Show comments
  • Thank you, I used:

    ou=OUwithinMyTopOU,OU=MyTopOU,DC=XXX,DC=XXX,DC=XXX,DC=XXX >> computers.txt -limit 999

    Everything worked perfect!
    Thanks again. - Newbie0000 8 years ago
    • remember the >> will append to the file not replace it (> replaces the file) so if you run it more then once it will be full extra machine names - SMal.tmcc 8 years ago
  • Thanks so much, I did not know that. - Newbie0000 8 years ago

Answers (1)

Answer Summary:
Posted by: SMal.tmcc 8 years ago
Red Belt
1

Top Answer

not at a domain computer to test but according to

https://technet.microsoft.com/en-us/library/cc730720.aspx

it should be like this

dsquery computer OU=Sales,DC=Contoso,DC=Com > file.txt
also see this for other dsquery calls

http://social.technet.microsoft.com/wiki/contents/articles/2195.active-directory-dsquery-commands.aspx



Comments:
  • dsquery.exe computer -name %COMPUTERNAME% > file.txt - aragorn.2003 8 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ