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.
To fix ‘dsquery’ is not recognized as an internal or external command, install RSAT tools and Turn on Remote Server Administration Tools, Role Administration Tools, and AD DS & AD LDS tools.
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 Commands
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:
Command | Description |
Dsquery * | Finds the groups in the active directory according to the specified search criteria. |
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 | Find the organizational units (OUs) in the active directory according to specified search criteria. |
Dsquery ou | Find 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 contact | Find the sites in the active directory that match the specified search criteria. |
Dsquery site | Find the contacts in the active directory that match the specified search criteria. |
Dsquery server | Finds the domain controllers in the active directory according to specified search criteria. |
Dsquery quota | Finds the sites in the active directory that match the specified search criteria. |
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 the 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!
Conclusion
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.
PowerShell dsquery commands can be helpful in finding specific object types in the Active Directory. It uses the LDAP to provide search criteria that help in searching the object types.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.