Get the SID for a local user account.
$username='julian'
$user = New-Object System.Security.Principal.NTAccount($username)
$sid = $user.Translate([System.Security.Principal.SecurityIdentifier])
$sid.Value
Get the local username from a SID.
$sid='S-1-5-21-5082059827-597078506-5194163137-1005'
$osid = New-Object System.Security.Principal.SecurityIdentifier($sid)
$user = $osid.Translate( [System.Security.Principal.NTAccount])
$user.Value