I’m not looking for User SIDs. I’m looking for the computer SID, which active directory would use to uniquely identify the computer. I also don’t want to query the active directory server, i want to query the computer itself.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(Ooh, this was a fun one! I went on a wild goose chase, as they say, trying to get the Win32_SID instance, which is a singleton and not enumerable by the usual InstancesOf or Query methods… yadda yadda yadda.)
Well, it depends which computer SID you want (seriously!). There’s the SID that the local computer uses for itself… For this, you just need to get the SID of the local Administrator user, and remove the “-500” from the end to get the computer’s SID.
In VBScript, it looks like this:
In PowerShell, like this:
In C# on .NET 3.5:
Results from all of these match the response I get from PsGetSid.exe.
On the other hand, there’s the SID that Active Directory uses to identify each domain member computer… That one you fetch by getting the SID of the machine account in the domain–the one that ends with a dollar sign.
E.g., using the above PowerShell function for a domain member called “CLIENT”, you can type
get-sid "CLIENT$".