Finding Groups of Logged On User

by Aug 17, 2016

If you’d like to know the group memberships of the currently logged on user (the one that is running a script), you don’t need to query the Active Directory. Instead, examine the access token. It contains all effective group memberships, including nested ones:

#requires -Version 1
  $groups = ([Security.Principal.WindowsIdentity]::GetCurrent()).Groups | 
  ForEach-Object {
  } | Sort-Object
  Write-Warning 'Groups could not be retrieved.' 


Twitter This Tip! ReTweet this Tip!