I was recently asked to find the username associated with a particular Active Directory SID (technically I was given the RID).
This is actually pretty easy in PowerShell, and quite intuitive using basic AD cmdlets.
Get the user for a given RID:
Get-ADUser -Filter * | Select-Object -Property SID,Name | Where-Object -Property SID -like "*-6640"
Get the SID for a given user:
Get-ADUser -Identity ad.user | Select-Object -Property Name,SID