Finds any objects in the directory according to criteria using an LDAP query.
To display, in table format, the SAM account names, user principal names, and departments of all users in the current domain whose SAM account name begins with the string "Jon", type:
dsquery * domainroot -filter "((objectCategory=Person)(objectClass=User)(sAMAccountName=Jon*)) -attr sAMAccountName userPrincipalName department
To read the SAM account names, User principal names, and department attributes of the object whose distinguished name is OU=Test,DC=Microsoft,DC=Com, type:
dsquery * OU=Test,DC=Microsoft,DC=Com -scope base -attr sAMAccountName userPrincipalName department
To read all attributes of the object whose distinguished name is OU=Test,DC=Microsoft,DC=Com, type:
dsquery * OU=Test,DC=Microsoft,DC=Com -scope base -attr *