search
top

Converting User Names to SIDs with Powershell

While doing some Active Directory work ran across a need to translate a user name to a SID (security identifier)  to help find traces of it in the registry. Here is an easy way to do this with PowerShell function.

function getSID($name, $domain=$env:userdomain) {
$objUser = New-Object System.Security.Principal.NTAccount($domain,$name)
$strSID =
$objUser.Translate([System.Security.Principal.SecurityIdentifier])
$strSID.Value
}

Try it with your login and see what you get.

PS:> getSID <yourid>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top