This question is inspired by a similar question using the C # tag. If I have a Windows SID and would like to convert it to a readable account name, how can I achieve this using PowerShell instead of C #?
I currently have the following code that retrieves group membership for the current user account:
$Identity = [System.Security.Principal.WindowsIdentity]::GetCurrent();
$Identity.Groups;
Property results Groupsdo not give me any account names, only SID. If I pass the output from the property Groupsto the PowerShell cmdlet Get-Member, I see that the resulting objects are objects System.Security.Principal.SecurityIdentifier. However, looking at the documentation (and Intellisense) for the property Groupsshows that it returns an object IdentityReferenceCollection.
How to convert these objects SecurityIdentifierto proper names?
source
share