Windows: Conversion between SID and username
Reference: MS Technet
We can use PowerShell to do query by SID or by username. Just copy and paste below command in a PowerShell:
| 
Local Account | 
Domain Account | |
| 
Account name to SID | 
$objUser = New-Object
  System.Security.Principal.NTAccount("username") 
$strSID =
  $objUser.Translate([System.Security.Principal.SecurityIdentifier]) 
$strSID.Value | $objUser = New-Object System.Security.Principal.NTAccount("mydomainname", "username")$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])$strSID.Value | 
| 
SID to account name | 
(Refer to this article) 
1.       
  Open Registry Editor and
  navigate to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion \ProfileList 
2.       
  Under the ProfileList key, you
  will see the SIDs. By selecting each one individually, you can look at the
  value entry and see what user name is associated with that particular SID. |  $objSID = New-Object System.Security.Principal.SecurityIdentifier `    ("S-1-5-21-1454471165-1004335555-1606985555-5555")$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])$objUser.Value | 
Comments