Determine SID object in Active Directory

Short article how to determine SID of known AD User and vice versa.

Determine SID of known AD User:

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

Determine which SID belongs to:

$objSID = New-Object System.Security.Principal.SecurityIdentifier ("S-1-5-21-XYZ")
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
$objUser.Value

 

You can find more here on technet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.