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
Life of a Geek Admin
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.