Q. How can I use a script to check an object's SID?

John Savill

January 24, 2008

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. The script below uses WMI to query the object's SID. In this example, I'm checking user John in domain savilltech. You can change these values to any object. Instead of a domain, you can use a computer name to get SIDs for local machine objects.

strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")

Set objAccount = objWMIService.Get _
("Win32_Account.Name='john',Domain='savilltech'")
Wscript.Echo objAccount.SID

Here is the result.

cscript getusersid.vbs
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
S-1-5-21-2835294230-785241407-2532694646-1106

Essentially, this script is a WMI lookup, outputting the object's SID attribute.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like