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 (8)
  1. Happy User says:

    Thanks, this was exactly what I needed!

  2. hankster37 says:

    Awesome script! I've added this to our documentation library. Great to have.

  3. doug diehl says:

    best way to read a text file with a bunch of sids into line one ?.. I have hundreds of sids like this I have to convert.. I'm a beginner so I'm looking for how to input mulitiple args

    S-1-5-21-1391787487-2401815557-2033200366-27291 CN=ForeignSecurityPrincipals DC=energy

  4. Kavita says:

    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.

  5. Michael says:

    Just what I need.


  6. Artyom says:

    what if a user's account had been deleted from Active Directory ?

  7. Rob says:

    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



Comments are closed.

Skip to main content