Translating SID to Username

by Oct 13, 2016

Ever wanted to translate a security identifier (SID) to the real name? Here is a function helping you:

#requires -Version 3.0

function ConvertFrom-SID
{
  param
  (
    [Parameter(Mandatory,ValueFromPipeline,ValueFromPipelineByPropertyName)]
    [Alias('Value')]
    $Sid 
  )
  
  process
  {
    $objSID = New-Object System.Security.Principal.SecurityIdentifier($sid)
    $objUser = $objSID.Translate( [System.Security.Principal.NTAccount])
    $objUser.Value
  }
}

You can submit a SID as an argument, or pipe one or multiple SIDs to the function.

Twitter This Tip! ReTweet this Tip!