Powershell – What groups AD user is a memeber of…

Ok, so a two-fer(sp?) today.  My last post quickly showed how to get a list of members of an Active Directory group. How about listing the groups an AD user account is a member of? Sure we can.  This time, we use the Get-ADPrincipalGroupMembership cmdlet!

Here ya go (don’t forget to import the AD module)…
get-adprincipalgroupmembership -Identity "<enter AD account here>" | select name | export-csv "<path to your .csv file goes here>"

Oh, and if you want to grab just a subset of groups that user is a member of, you can use get-adgroup cmdlet with the -filter added on.  For example:
get-adgroup -filter {name -like "VDI-*"} -Properties Description | select Name,Description | Export-csv -path  -NoTypeInformation

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.