Dsquery Command

Dsquery Command

Description: Finds domain controllers according to specified search criteria.

Syntax: dsquery server [-o {dn | rdn}] [-forest]

[-domain <DomainName>] [-site <SiteName>]

[-name <Name>] [-desc <Description>]

[-hasfsmo {schema | name | infr | pdc | rid}] [-isgc]

[{-s <Server> | -d <Domain>}] [-u <UserName>]

[-p {<Password> | *}] [-q] [-r] [-gc]

[-limit <NumObjects>] [{-uc | -uco | -uci}]

-forest

Finds all domain controllers (DCs) in the current forest.

Example:

C:\Documents and Settings\shabari>dsquery server -forest -limit 05

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory2,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJHQ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJHQ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=DcinsideactivedirectoryG1,CN=Servers,CN=Georgia,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

-domain <DomainName>

Finds all DCs in the domain with a DNS name matching <DomainName>.

Example:

C:\Documents and Settings\shabari>dsquery server -domain insideactivedirectory.net -u insideactivedirectory\shabari -p *

Enter Password:*******

“CN=DC1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=,DC=insideactivedirectory,DC=com”
“CN=DC2,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=,DC=insideactivedirectory,DC=com”
“CN=DC3,CN=Servers,CN=Paris,CN=Sites,CN=Configuration,DC=,DC=insideactivedirectory,DC=com”
“CN=DC4,CN=Servers,CN=Paris,CN=Sites,CN=Configuration,DC=,DC=insideactivedirectory,DC=com”

-site <SiteName>

Finds all DCs that are part of site <SiteName>.

Example:

C:\Documents and Settings\shabari>dsquery server -site bangalore

“CN=Dcinsideactivedirectory4,CN=Servers,CN=Bangalore,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory1,CN=Servers,CN=Bangalore,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory2,CN=Servers,CN=Bangalore,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
-name <Name>

Finds DCs with names matching the value given by <Name>, e.g., “NA*” or “Europe*” or “j*th”.

Example:

C:\Documents and Settings\shabari>dsquery server -name dcinsideactivedirectory1

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

-desc <Description>

Finds DCs with descriptions matching the value given by <Description>, e.g., “corp*” or “j*th”.

Example:

C:\Documents and Settings\shabari>dsquery server -desc NYJ*

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

-hasfsmo {schema | name | infr | pdc | rid}

Finds the DC that holds the specified Flexible Single-master Operation (FSMO) role. (For the “infr,” “pdc” and “rid” FSMO roles, if no domain is specified with the -domain parameter, the current domain is used.)

Example:

C:\Documents and Settings\shabari>dsquery server -hasfsmo schema

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

C:\Documents and Settings\shabari>dsquery server -hasfsmo name

“CN=Dcinsideactivedirectory2,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

C:\Documents and Settings\shabari>dsquery server -hasfsmo infr

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

C:\Documents and Settings\shabari>dsquery server -hasfsmo pdc

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

C:\Documents and Settings\shabari>dsquery server -hasfsmo rid

“CN=Dcinsideactivedirectory3,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

-isgc

Find all DCs that are also global catalog servers (GCs) in the scope specified (if the -forest, -domain or -site parameters are not specified, then find all GCs in the current domain are used).

Example:

C:\Documents and Settings\shabari>dsquery server -isgc

“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory2,CN=Servers,CN=NYJ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com” “CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJHQ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory1,CN=Servers,CN=NYJHQ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”
“CN=Dcinsideactivedirectory2,CN=Servers,CN=NYJHQ,CN=Sites,CN=Configuration,DC=insideactivedirectory,DC=com”

Remarks:

The dsquery commands help you find objects in the directory that match a specified search criterion: the input to dsquery is a search criteria and the output is a list of objects matching the search. To get the properties of a specific object, use the dsget commands (dsget /?). If a value that you supply contains spaces, use quotation marks around the text (for example, “CN=JohnSmith,CN=Users,DC=microsoft, DC=com”). If you enter multiple values, the values must be separated by spaces

Cheerio,

Dinesh Patil