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

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 & "\root\cimv2")

Set objAccount = objWMIService.Get _
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.

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

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.