ActiveDirectory

Using DSQUERY to find users and groups

Using DSQUERY to find users and groups

In huge AD infrastructures with several OUs and thousands of users and/or computers, it becomes difficult many times to be able to locate users/computers and which OU structure they reside in.  A very handy command line tool for AD administrators is the DSQUERY utility.  This command line tool is built into Windows 2008 when the domain services role is installed.  Administrators may also avail themselves to this beneficial tool on their Windows 7 workstations by installing the Remote System Administration Toolkit.  The official Technet article is found here describing the functionality of this command line utility. DSQUERY can do many different things and can be used in conjunction with other command line utilities found in the DS* family by the way of piping.

Finding a User or Computer:

As mentioned above, one of the simple handy things that DSQUERY can do for you is locate a user or computer. The syntax is as follows:

  • dsquery user -name “%USERNAME%”
  • dsquery computer -name “%COMPUTERNAME%”

 

User:

dsquery1

 

Computer:

dsquery2

 

Final Thoughts:

DSQUERY is another one of those must use and have utilities for administrators that just makes their lives much easier.  It provides functionality ranging from simple tasks as we have described here as well as much more complex queries in conjunction with other command line utilities.

 

Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.