Dsquery

Queries the directory by using search criteria that you specify. Each of the dsquery commands finds objects of a specific object type.

Dsquery is a command-line tool that is built into Windows server if you have the Active Directory Domain Services (AD DS) server role installed. To use dsquery, you must run the dsquery command from an elevated command prompt.

What object can dsquery work on?

Command

Description

Dsquery computer

Finds computers in the directory that match search criteria that you specify.

Dsquery contact

Finds contacts in the directory that match search criteria that you specify.

Dsquery group

Finds groups in the directory that match search criteria that you specify. If the predefined search criteria in this command are insufficient, use the general version of the query command, dsquery *.

Dsquery ou

Finds organizational units (OUs) in the directory that match search criteria that you specify. If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

Dsquery site

Finds sites in the directory that match search criteria that you specify. If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

Dsquery server

Finds domain controllers according to specified search criteria. If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

Dsquery user

Finds users in the directory that match search criteria that you specify. If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

Dsquery quota

Finds quota specifications in the directory that match search criteria that you specify. A quota specification determines the maximum number of directory objects a specified security principal can own in a given directory partition.

If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

Dsquery partition

Finds partition objects in the directory that match search criteria that you specify. If the predefined search criteria in this command are insufficient, use the more general version of the query command, dsquery *.

Dsquery *

Finds any objects in the directory according to criteria using an LDAP query.

The results from a dsquery search can be piped as input to one of the other directory service command-line tools, such as Dsget, Dsmod, Dsmove, or Dsrm. For example, you want to find out the login username according to the user last name:

DSQUERY USER -name *lastname* | DSGET USER -samid -display

 

 

Dsget

Displays the selected properties of a specific object in the directory.

There are also a few commands for Dsget:

Command

Description

Dsget computer

Displays the properties of a computer in the directory.

There are two variations of this command. The first variation allows you to view the properties of multiple computers. The second variation allows you to view the membership information of a single computer.

Dsget contact

Displays the various properties of a contact in the directory.

Dsget group

Displays the various properties of a group including the members of a group in the directory. There are two variations of this command. The first variation allows you to view the properties of multiple groups. The second variation allows you to view the group membership information of a single group.

Dsget ou

Displays the various properties of an organizational unit in the directory.

Dsget server

Displays the various properties of a domain controller defined in the directory.

There are three variations of this command. The first variation displays the general properties of a domain controller that you specify. The second variation displays a list of the security principals who own the largest number of directory objects on the domain controller that you specify. The third variation displays the distinguished names of the directory partitions on the server that you specify.

Dsget user

Displays the properties of a user in the directory. There are two variations of this command. The first variation allows you to view the properties of multiple users. The second variation allows you to view the group membership information of a single user.

Dsget subnet

Displays the properties of a subnet that is defined in the directory.

Dsget site

Displays the properties of a site that is defined in the directory.

Dsget quota

Displays the properties of a quota specification that is defined in the directory. A quota specification determines the maximum number of directory objects that a given security principal can own in a specific directory partition.

Dsget partition

Displays the properties of a directory partition.