Click to Rate and Give Feedback
TechNet
TechNet Library
Windows Server
A-Z List
Dsquery
Dsquery

Updated: December 1, 2007

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2008, Windows Server 2008 R2

Queries the directory by using search criteria that you specify. Each of the dsquery commands finds objects of a specific object type, with the exception of dsquery *, which can query for any type of object

Dsquery is a command-line tool that is built into Windows Server 2008. It is available 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. To open an elevated command prompt, click Start, right-click Command Prompt, and then click Run as administrator.

Commands

 

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.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
membership is an atribute not an object      Martin.Stejskal   |   Edit   |   Show History

You canot use dsquery to query attributes, only for object query according to their attirbutes.

You must use it together with dsget to aquire the attribute of each user object you choose via dsquery.

the attirbute is called member of (for strict name look at technet) and is enumerated dynamicly during the query (So GC plays its role here).

There sure will be some samle codes on technet or elsewhere.
This is also deeply discused in self study kit for the 70-640 Microsoft Exam! So using or understanding such scripts or piped CMD is probably part of that exam.


Also alternatively you can use some AD export utility such CSVDE or LDIFDE where you dont need to be experienced in sript writing and you can achive the same results with export file output for excel or the LDIF format

Tags What's this?: Add a tag
Flag as ContentBug
the list of user is the member of which group      rini gaur   |   Edit   |   Show History
Hi,

I Have the list of user i want to know that user's is the member of which group by a dsquery and dsget i have the output but only for a single user not the list of the user because its not shows the user name in the output.
So If someone have the solution kindly share i will be greate full.

Thanks..
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker