Ever come across something like this: S-1-5-21-9378569023-29138639125-19468 and wonder what it is? Try feeding it to this handy little function:

function Translate-SID
{
 param([string]$SID)
 $objSID = New-Object System.Security.Principal.SecurityIdentifier($SID)
 $objUser = $objSID.Translate([System.Security.Principal.NTAccount])
 Return $objUser.Value
}

Of course, you might feel the need to reverse this process and turn something perfectly fine like DOMAINUser into the illegible garbage that is known as a SID. Well, have it your way:

function Translate-ToSID
{
 param([string]$ID)
 $objID = New-Object System.Security.Principal.NTAccount($ID)
 $objSID = $objID.Translate([System.Security.Principal.SecurityIdentifier])
 Return $objSID.Value
}

Have a good one.
Hugo

No related posts.

  2 Responses to “Handy little function: Translate-SID”

  1. Hi Hugo,
    you are the ONE! Very nice, useful and easy. I love it :)

    Thanks,
    David

  2. Hello David,
    Glad I could have been of assistance.
    Stay tuned for more handy functions soon!
    Greetings, Hugo

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

   
© 2012 PeetersOnline Suffusion theme by Sayontan Sinha