ActiveDirectory

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.

 

Back to top button