Sharing Knowledge | System Admin Articles

How to Display the Groups a User is a Member of

I've been trying to work more and more with scripts and today I'm sharing a simple but useful one. How to display the groups a user account is a member of. To display a user's groups via the command prompt you need to use the dsget command with the -memberof and -expand switches. The -expand command will list all of the groups that you belong to that are nested in other groups.

Below is an example of how this would look:

dsget user "CN=Brian W. McCann,OU=Users,OU=Sales,DC=Adminprep,DC=com" -memberof -expand

The output would look similar to this:
"CN=GG Sales,OU=Groups,OU=Sales,DC=Adminprep,DC=com"
"CN=Domain Admins,CN=Users,DC=Adminprep,DC=com"
"CN=Domain Users,CN=Users,DC=Adminprep,DC=com"
"CN=GG Inside Sales,OU=Groups,OU=Sales,DC=Adminprep,DC=com"
"CN=GG Outside Sales,OU=Groups,OU=Sales,DC=Adminprep,DC=com"

Labels: Windows

About the Author
My Profile Photo

I'm Shankar, A Windows System Admin. I'm Experienced in Windows Server Technologies and Citrix Administration. I'm blogging since 2009 and I'm currently working for a Organization as Senior System Engineer.
Follow Me On Twitter or On Facebook

0 Comments for "How to Display the Groups a User is a Member of"

What do you think about this Article? Add your Opinion..!

Back To Top