For more technical explainers on PowerShell, read our updated 2021 report: PowerShell 101: A Technical Explainer for IT Pros.
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.
1 comment
Hide comments