How do I get a user or group SID?

For a User Run

strComputer = "."
strUser = "User"
strDomain = "domain"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='" & strUser &"',Domain='''& strDomain &"'")
Wscript.Echo objAccount.SID

For a Group Use

strComputer = "."
strGroup = "GROUPNAME"
strDomain = "DOMAIN"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get("Win32_Group.Name='" & strGroup &"',Domain='"& strDomain &"'")
Wscript.Echo objAccount.SID

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading