Get the SID of an Active Directory User

Can’t remember why I needed to, but if you need to get the SID of an Active Directory user account you can run either of these powershell scripts:

1 $name= “username”
2 (New-ObjectSystem.Security.Principal.NTAccount($name)).Translate([System.Security.Principal.SecurityIdentifier]).value

or

1 $objUser= New-ObjectSystem.Security.Principal.NTAccount("fabrikam", "kenmyer")
2 $strSID= $objUser.Translate([System.Security.Principal.SecurityIdentifier])
3 $strSID.Value


你可能感兴趣的:(user,get,sid,Directory,Active,of,the,An)