Skip to content

Instantly share code, notes, and snippets.

@polarnik
Created December 29, 2014 05:58
Show Gist options
  • Save polarnik/676dad10d40d46078c4f to your computer and use it in GitHub Desktop.
Save polarnik/676dad10d40d46078c4f to your computer and use it in GitHub Desktop.
Get current user SID, VBS, WMI
Dim ADSysInfo
Dim sUserName
Dim objWMIService
Set ADSysInfo = CreateObject("ADSystemInfo")
Set sUserName = GetObject("LDAP://" & ADSysInfo.UserName)
strComputer = "."
strResult = ""
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
For Each objAccount in objWMIService.InstancesOf("Win32_UserAccount")
if objAccount.Name = sUserName.cn then
strResult = strResult & objAccount.Domain & "\" & objAccount.Name & ": " & objAccount.FullName & " => " & objAccount.SID & vbCR
end if
Next
Wscript.Echo strResult
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment