Wednesday, October 17, 2012

Script to get user SID

Just some weeks ago I ended up in a situation where I needed to get a user SID (Security Identifier). I found a good script on the net that I just needed to modify a little.

Just log in as the user you need SID for and run this script:

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

Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='xxxx',Domain='yyy'")
Wscript.Echo objAccount.SID"

replace xxxx with you user name and domain yyy.
Depending on your settings you'll get the output as alertbox or in the cmd.

(verified on windows server 2003)

No comments:

Post a Comment