Some time we will be having requirement to convert SID to Group/User Name or Group/User Name to SID. Here I will show you simple way to do that using PowerShell.
How to Convert Group/User Name to SID:
Syntax:
$Name = “Group or User Name”
(New-Object System.Security.Principal.NTAccount($Name)).Translate([System.Security.Principal.SecurityIdentifier]).value
Example:
$Name = “Trace-Restriction”
(New-Object System.Security.Principal.NTAccount($Name)).Translate([System.Security.Principal.SecurityIdentifier]).value
How to Convert SID to Group/User Name:
Syntax:
$Name = “SID ID”
(New-Object System.Security.Principal.SecurityIdentifier($Name)).Translate([System.Security.Principal.NTAccount]).value
Example:
$Name = “S-1-5-21-57989841-616249376-1801674531-1846207”
(New-Object System.Security.Principal.SecurityIdentifier($Name)).Translate([System.Security.Principal.NTAccount]).value