Windows: Conversion between SID and username

Reference: MS Technet

We can use PowerShell to do query by SID or by username.  Just copy and paste below command in a PowerShell:

Local Account
Domain Account
Account name to SID
$objUser = New-Object System.Security.Principal.NTAccount("username")
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])

$objUser = New-Object System.Security.Principal.NTAccount("mydomainname", "username")
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])

SID to account name
(Refer to this article)
1.        Open Registry Editor and navigate to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion \ProfileList
2.        Under the ProfileList key, you will see the SIDs. By selecting each one individually, you can look at the value entry and see what user name is associated with that particular SID.

$objSID = New-Object System.Security.Principal.SecurityIdentifier `
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])


Popular Posts