In the previous tip we illustrated how you can find out the direct and indirect group memberships for a user. If you’d like to know the memberships for the current user, there is a much easier (and faster) approach: use the access token for the current user to retrieve the current effective group memberships:

$groups = [System.Security.Principal.WindowsIdentity]::GetCurrent().Groups.Translate([System.Security.Principal.NTAccount]) 

$groups

$groups.Count

Twitter This Tip! ReTweet this Tip!

Anonymous