Q. How can I find the SID of a user or other object using PowerShell?
A. There are a number of different methods to find the SID of an object. A simple way is as follows:
$name = '[email protected]' (New-Object System.Security.Principal.NTAccount($name)).Translate([System.Security.Principal.SecurityIdentifier]).value
Simply change the name of the object in the $name variable. Note the above is really a condensed version of:
$AdObj = New-Object System.Security.Principal.NTAccount('[email protected]') $strSID = $AdObj.Translate([System.Security.Principal.SecurityIdentifier]) $strSID.Value
Another option to find the name of a user account is using Get-ADUser:
Get-ADUser -Identity 'honeypot' | select SID
You could also use Get-ADGroup and other cmdlets for other types of object.