Home » Dsquery » Dsquery Commands

Dsquery Commands

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.

dsquery command
dsquery command

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:

CommandDescription
Dsquery *Finds objects in the active directory according to search
criteria using an LDAP query.
Dsquery userFinds the user objects in the active directory according to specified search criteria.
Dsquery computerFinds the computers in the active directory according to
specified search criteria.
Dsquery groupFinds the groups in the active directory according to specified
search criteria.
Dsquery ouFinds the organizational units (OUs) in the active directory
according to specified search criteria.
Dsquery contactFinds the contacts in the active directory that matches the specified search criteria.
Dsquery siteFinds the sites in the active directory that matches the specified search criteria.
Dsquery serverFinds the domain controllers in the active directory according to
specified search criteria.
Dsquery quotaFinds 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 partitionFinds the partition objects in the active directory that matches the specified search criteria.
dsquery commands

How to run dsquery?

To use dsquery to find objects in the active directory, open the command prompt in elevated mode ( Run As Administrator).

run dsquery in command prompt
run dsquery in command prompt

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!

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.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Leave a Comment