Convert SID to User Name using PowerShell

Create a SecurityIdentifier object and translate into a NTAccount:

    1:  $objSID = New-Object System.Security.Principal.SecurityIdentifier 
    1:     ("S-1-5-21-3496554487-1900509739-3140548133-500")
    2:  $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
    3:  $objUser.Value

Comments

  • Anonymous
    December 24, 2014
    Thanks, this was exactly what I needed!

  • Anonymous
    February 05, 2015
    Awesome script! I've added this to our documentation library. Great to have.

  • Anonymous
    February 10, 2015
    technet.microsoft.com/.../ff730940.aspx

  • Anonymous
    August 12, 2015
    The comment has been removed

  • Anonymous
    August 25, 2015
    I have a list of SID's. How can i import a file and get the result? As the above example is for single SID.

  • Anonymous
    September 09, 2015
    Just what I need. Thanks.

  • Anonymous
    November 23, 2015
    what if a user's account had been deleted from Active Directory ?

  • Anonymous
    February 22, 2016
    If the account has been deleted the translate will simply fail You could use a try catch construction and return the SID in that case for example Try {  $User = $objSID.Translate( [System.Security.Principal.NTAccount]).Value } Catch {  $User = $objSID.Value } $user