Home » Dsquery » Dsquery Server – Find All Domain Controllers

Dsquery Server – Find All Domain Controllers

The Dsquery Server command is used to find all domain controllers that match the specified search criteria.

Using the dsquery server, you can find all domain controllers in the forest or site or in the domain that are global catalog servers.

If the search criteria in the dsquery server command are not sufficient, use a general version of the query command dsquery *.

To use the dsquery server to find the domain controller, open the command prompt and run as administrator.

Dsquery Server

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 <NumberOfObjects>] [{-uc | -uco | -uci}]

Dsquery Server to Find Domain Controller using cmd

Use the Dsquery server in the command prompt (cmd) to find the domain controller in the current domain.

dsquery server

The output of the above command gets the domain controller using cmd.

Dsquery Server - Find Domain Controller using CMD
Dsquery Server – Find Domain Controller using CMD

List All Domain Controllers in the Forest using Dsquery Server

The dsquery server has parameter rdn that displays the relative distinguished name and forest to search for all domain controllers in the forest.

Refer to the following code where the dsquery server uses the parameters rdn and forest to list all domain controllers in the forest.

dsquery server -o rdn -forest

The output of the above command finds all domain controllers in the forest and displays their distinguished names.

C:\>dsquery server -o rdn -forest
"ENGG-PRO"

C:\>

Cool Tip: Use Dsquery to export group members to a CSV file!

Find Domain Controllers in the Site

To list all domain controllers in the site that matches the specified search criteria for the site, use the dsquery server to retrieve domain controllers distinguished names.

dsquery server -o rdn -site Houston

In the above command, the dsquery server finds the domain controllers in the site Houston and returns their distinguished names.

C:\>dsquery server -o rdn -site Houston
"ENGG-PRO"

C:\>

List all Domain Controllers in the Global Catalog Servers

To get all domain controllers that are part of the global catalog servers, use the following command.

dsquery server -domain SHELLPRO.LOCAL -isgc

The output of the above command gets the domain controllers.

C:\>dsquery server -domain SHELLPRO.LOCAL -isgc
"CN=ENGG-PRO,CN=Servers,CN=Houston,CN=Sites,CN=Configuration,DC=SHELLPRO,DC=LOCAL"

C:\>

Conclusion

I hope the above article on how to find domain controllers using the Dsquery server command in cmd is helpful to you.

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