Created
December 29, 2014 05:58
-
-
Save polarnik/676dad10d40d46078c4f to your computer and use it in GitHub Desktop.
Get current user SID, VBS, WMI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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