SID, User Names, and Active Directory

More of a snippet for me to refer to later, but here's a quick way to convert a SID (Security Identifier) to a user's name in AD:

PS D:\> $sid = 'S-1-5-21-3160822684-348306091-3778041397-7630'
PS D:\>  [adsi]"LDAP://<SID=$sid>"

distinguishedName
-----------------
{CN=John Doe,OU=...

This is handy because registry entries are stored as paths under HKEY_USERs.