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:
Computer:
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.