List All Group Memberships of Current User

In case you need to get a list of all of your current Group memberships as derived from your current access token, use this line:

([System.Security.Principal.WindowsIdentity]::GetCurrent()).Groups |
Foreach-Object { $_.Translate([System.Security.Principal.NTAccount])}

The result is a list of Group names that reflect current members, which accurately reflects the Group memberships as they are defined in your current access token that you received at last log-on.


Posted May 14 2009, 08:00 AM by ps1

Comments

irwins wrote re: List All Group Memberships of Current User
on 12-09-2010 3:13 AM

Is there a vbs equivalent t to this? Just wondering...

Izz Noland B Abdullah wrote re: List All Group Memberships of Current User
on 01-04-2011 2:55 PM

the vbs is something like this:

------

Set objSysInfo = CreateObject("ADSystemInfo")

strUserDN = objSysInfo.UserName

strAdsPath = "LDAP://" & strUserDN

strLDAP = strAdsPath

Set objUser = GetObject(strLDAP)

objmemberOf  = objUser.GetEx("memberOf")

For Each objGroup in objmemberOf

  strList = strList & objGroup & vbcr

Next

WScript.Echo "Groups for " & strUser & vbCr & strList

WScript.Quit

------

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.