List users in an AD group

If you want to quickly list all the users in a group (and even count them) you need the DN name of the group and the following line entered in cmd or PowerShell:

dsget group "CN=Group,DC=Contoso,DC=com" -members -expand

This will list all the users/groups that are members of that group. To find out the number of members pipe the output to find using the c switch (all DN have a DC in their name):

dsget group "CN=Group,DC=Contoso,DC=com" -members -expand | find /c "DC"

Hint: If you use a special syntax for groups (group_groupname or abreviation_groupname) you can exclude all the groups (using find’s v switch) and you will find only the users in that group.

dsget group "CN=Group,DC=Contoso,DC=com" -members -expand | find /c /v "group_"

Leave a Reply

Your email address will not be published. Required fields are marked *