Home » Dsquery » Dsquery – Get User All Attributes

Dsquery – Get User All Attributes

Use the dsquery command with the attr * parameter to get user all attributes. -attr {<AttributeList> | *} parameter is used to retrieve multiple attributes for the user. If you specify the value of attr value as a wildcard character (*), it will display all attributes for the user.

Using the dsquery command with the specified search criteria for the user, it will list all user attributes.

In this tutorial, we will discuss how to get user attributes list for the user using dsquery and find all attributes for all users.

Dsquery Get User All Attributes

Use the general version of the dsquery * command to get the user attributes list for the user specified in the search criteria.

In the below dsquery * command, it uses filter condition to check for the user samaccountname=toms , and using the attr * parameter, it displays the available multiple attributes list for the user.

dsquery * -filter "samaccountname=toms" -attr *

In the above dsquery user attributes example, it will display all attributes for the user as given below.

dsquery - user all attributes example
dsquery – user all attributes example

In the above output, it can be seen that the user object in the active directory has multiple attributes like cn, sn, givenname, distinguishedName, displayName, pwdLastSet, etc…

Find all attributes for users using dsquery

Use the dsquery * command with LDAP query in the filter parameter to search for all users in the active directory. -attr * parameter is used to display all attributes for the users.

In the below command to find all attributes for the users using the dsquery command,

  • It uses a filter parameter to specify the LDAP query to search objects of the specific type in the active directory.
  • attr parameter with a wildcard character (*) like attr * is used to display all attributes for the user.
  • limit parameter specifies the count of users to get. If the limit parameter has a 0 value, it will list all users available in the active directory.
  • ObjectClass = User and ObjectCategory = Person query search for the users in the active directory.
Dsquery * -limit 0 -filter "&(objectClass=User)(objectCategory=Person)" -attr *

In the above dsquery command to get all user attributes example, the output displays all attributes list for the users in the directory.

dsquery - find all users attributes example
dsquery – find all users’ attributes example

Conclusion

I hope the above article on how to use the dsquery command to retrieve a list of all attributes for the user and find all attributes for all users in the directory is helpful to you.

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