Dsquery is a command-line tool that is available on Windows Server and available if Active Directory Domain Services (AD DS) is installed.
Dsquery is used to query the active directory by using the specified search criteria.
Dsquery has commands available to query the active directory to find objects of the specific object type.
In this article, you will learn about the dsquery command, the dsquery commands list, and how to run the dsquery in cmd and PowerShell.
Dsquery command-line tools have many commands to find the specific object types in the active directory. It uses LDAP queries to provide search criteria.
Using the dsquery command with an LDAP query, it finds objects in the active directory that matches the specified search criteria using an LDAP query.
Use the general version of the dsquery command, dsquery * if the search criteria specified in the dsquery commands are insufficient to get results.
Dsquery commands are as given below:
|Dsquery *||Finds objects in the active directory according to search |
criteria using an LDAP query.
|Dsquery user||Finds the user objects in the active directory according to specified search criteria.|
|Dsquery computer||Finds the computers in the active directory according to |
specified search criteria.
|Dsquery group||Finds the groups in the active directory according to specified|
|Dsquery ou||Finds the organizational units (OUs) in the active directory|
according to specified search criteria.
|Dsquery contact||Finds the contacts in the active directory that matches the specified search criteria.|
|Dsquery site||Finds the sites in the active directory that matches the specified search criteria.|
|Dsquery server||Finds the domain controllers in the active directory according to|
specified search criteria.
|Dsquery quota||Finds the quota specifications in the active directory that matches the specified search criteria. A quota specification determines the maximum number of directory objects a specified security principal owns in a given directory partition.|
|Dsquery partition||Finds the partition objects in the active directory that matches the specified search criteria.|
How to run dsquery?
To use dsquery to find objects in the active directory, open the command prompt in elevated mode ( Run As Administrator).
To open the command prompt with an elevated mode, follow the below steps
- Search cmd in window search
- Right-click on the command prompt and click Run as administrator
You can use PowerShell to run the dsquery command in Windows PowerShell.
How to install dsquery on Windows 10?
If you try to run the dsquery command on Windows 10 system, it will display the below error message”
'dsquery' is not recognized as an internal or external command,operable program or batch file.“
To install the dsquery command-line tool on the Microsoft Windows 10 operating system, the system must have RSAT (Remote Server Administration Tools) installed.
To install RSAT, follow the given below steps
- Go to Apps and Features
- Click Manage optional features
- Click Add a Feature
- Install RSAT
- Go to Windows Features control panel
- Turn on “Remote Server Administration Tools, Role Administration Tools, and AD DS and AD LDS Tools”
Cool Tip: How to use the dsquery * command to get user last logon!
I hope the above article on the dsquery command is helpful in understanding dsquery and dsquery commands available to query directories to find objects of the specific type.