Primoz Primoz - 3 months ago 9
PowerShell Question

How to get all groups that a user is a member of?

PowerShell's

cmdlet returns members of a specific group. Is there a cmdlet or property to get all the groups that a particular user is a member of?




I fixed my mistake:
Get-Member
should be
Get-ADGroupMember
.

Answer

Get group membership for a user:

$strUserName = "Primoz"
$strUser = get-qaduser -SamAccountName $strUserName
$strUser.memberof

See Get Group Membership for a User

But also see Quest's Free PowerShell Commands for Active Directory.

[Edit: Get-ADPrincipalGroupMembership command is included in Powershell since v2 with Windows 2008 R2. See kstrauss' answer below.]