I often find myself running the following PowerShell command to figure out a user’s AD group membership:

Get-ADUser <username> -Properties MemberOf | Select -Expand MemberOf

I’ve written a little helper function that lives in my PowerShell profile (at the moment to replace this with the following syntax:

Get-ADUserGroupMembership <username>

Here’s the (very simple) code for the function. No error handling, mind you, but it saves me a bit of typing each time.

function Get-ADUserGroupMembership {
    Get-ADUser $username -Properties MemberOf | Select -Expand MemberOf

Leave a Reply

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

You are commenting using your 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