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"

Share this

Related Posts

Next Post »

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