How To Grab Windows SIDs with PowerShell
There are those times where you just need those SIDs, no matter what door you knock on. For those fateful times, you can use this snippet of code to grab the SID from a given target user.
#this is the target user name
$username = "SomeDomainSomeUserName";
# get the account object
$account = New-Object System.Security.Principal.NTAccount $username;
# then get the sid value from it
$sid = $account.Translate([System.Security.Principal.SecurityIdentifier]).Value;
# or just do it all at once
$sid = (New-Object System.Security.Principal.NTAccount $username).Translate([System.Security.Principal.SecurityIdentifier]).Value;