Search for a server in active directory.
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}] Key -o The format used to display the search results. dn = distinguished name. rdn = relative distinguished name. -forest Search for all domain controllers (server objects) that are part of the current forest. -domain Search for all domain controllers (server objects) that are part of domain (DNS name) default=current domain. -site Search for all domain controllers (server objects) that are part of SiteName. -name Search for Server object(s) whose name attribute(CN) matches Name. For example, "br*" -desc Search for Server object(s) whose description matches. For example, "contractor*" -hasfsmo Match the Domain Controller operations master role: schema Schema master of the forest. name Domain naming master of the forest. infr Infrastructure master of the domain. pdc Primary domain controller (PDC) role owner. rid Relative identifier master (RID master) -isgc Search for all domain controllers (server objects) that are Global Catalog servers. -s Server to connect to (Default=the domain controller in the logon domain.) -d Domain to connect to. -u Username with which the user logs on to a remote server. -p Password (UserName or Domain\UserName or Username@domain.com) -q Quiet, suppress all output -r Recursive search (follow referrals) -gc Use the AD global catalog during the search. -limit The maximum number of objects to return, default=100. -uc Unicode format -uco Unicode format for output only -uci Unicode format for input only
Examples
Find all domain controllers in the current domain:
C:\> dsquery server
Find all domain controllers in the domain ss64.com that are global catalog servers:
C:\> dsquery server -domain ss64.com -isgc
“We don’t pay taxes. Only the little people pay taxes” ~ Leona Helmsley
Related:
DSAdd - Add object.
DSMod - Modify object.
DSGet - Display object.
DSMove - Move object.
DSQuery - Search for objects.
DSRM - Delete object.
PowerShell: Get-adComputer - Get one or more AD computers.