DSQuery Contact (installable option via RSAT /AD DS)

Search for contacts in active directory.

      DSQuery Contact [{StartNode | forestroot | domainroot}]
        [-o {dn | rdn | samid}]  [-scope {subtree | onelevel | base}]
           [-name Name] [-desc Description] 
              [{-s Server | -d Domain}] [-u UserName] [-p {Password | *}]
                 [-q] [-r] [-gc] [-limit NumberOfObjects]  [{-uc | -uco | -uci}]

   StartNode | forestroot | domainroot  The node in the console tree where the search starts.
                                        forestroot = search using the global catalog. 

   -o       The format used to display the search results.
               dn = distinguished name. 
               rdn = relative distinguished name.
               samid = Security Accounts Manager (SAM) account name.

   -scope   The scope of the search:
               subtree = subtree that is rooted at the start node in the console tree.
               onelevel = immediate children of the start node only.
               base = single object that the start node represents.
            If forestroot is the StartNode, then subtree is the only valid scope. 

   -name    Search for contact(s) whose name attribute(CN) matches Name.
            For example, "br*"

   -desc    Search for contact(s) whose description matches. For example, "contractor*"

   -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.


Find all contacts on the current domain with a name that starts with 'Smit'

C:\> dsquery contact -name Smit*

Find all contacts in a specific OU:

C:\> dsquery contact ou=users,ou=AcmeCo,dc=ss64,dc=com

"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us" ~ Calvin & Hobbes

Related commands

DSQuery User - Search for users.
DSAdd - Add object. DSAdd Contact - Add a contact to active directory.
DSMod - Modify object. DSMod Contact - Modify a contact in active directory.
DSGet - Display object. DSGet Contact - Display contact(s) from active directory.
DSMove - Move object.
DSQuery - Search for objects.
DSRM - Delete object.
PowerShell: Get-adObject - Get one or more AD objects.

Copyright © 1999-2024 SS64.com
Some rights reserved