Examples: To find all computers that have been inactive for the last four weeks and remove them from the directory: dsquery computer -inactive 4 | dsrm To find all users in the organizational unit "ou=Marketing,dc=microsoft,dc=com" and add them to the Marketing Staff group: dsquery user ou=Marketing,dc=microsoft,dc=com | dsmod group "cn=Marketing Staff,ou=Marketing,dc=microsoft,dc=com" -addmbr To find all users with names starting with "John" and display his office number: dsquery user -name John* | dsget user -office To display an arbitrary set of attributes of any given object in the directory use the dsquery * command. For example, to display the sAMAccountName, userPrincipalName and department attributes of the object whose DN is ou=Test,dc=microsoft,dc=com: dsquery * ou=Test,dc=microsoft,dc=com -scope base -attr sAMAccountName userPrincipalName department To read all attributes of the object whose DN is ou=Test,dc=microsoft,dc=com: dsquery * ou=Test,dc=microsoft,dc=com -scope base -attr * Directory Service command-line tools help: dsadd /? - help for adding objects. dsget /? - help for displaying objects. dsmod /? - help for modifying objects. dsmove /? - help for moving objects. dsquery /? - help for finding objects matching search criteria. dsrm /? - help for deleting objects.
Examples: To display the description and phone numbers for contacts "Jon Smith" and "Jona Jones". dsget contact "CN=John ...
Examples: To enable the domain controllers CORPDC1 and CORPDC9 to become global catalog servers: dsmod server "cn=CORPDC ...
Examples: To find all computers in a given OU whose name starts with "tst" and show their descriptions. dsquery computer ...
Examples: To find all computers in the current domain whose name starts with "ms" and whose description starts with "desktop", ...
Examples: To find all computers that have been inactive for the last four weeks and remove them from the directory: dsquery ...
Examples: To find all connections for server CORPDC1 and show their from-end servers and enabled states. dsquery conn -to ...
Examples: To find all DCs in the current domain: dsquery server To find all DCs in the forest and display their Relative ...
Examples: To find all domain controllers for domain corp.microsoft.com and display their DNS host name and site name: dsquery ...
Examples: To find all groups in a given OU whose names start with "adm" and display their descriptions. dsquery group ou=Test,dc=microsoft,dc=com ...