I'm using vbscript to interact with the WMI classes. I am querying the Win32_GroupUser
class which is defined here https://msdn.microsoft.com/en-us/library/windows/desktop/aa394153%28v=vs.85%29.aspx.
In the definition, it has the following components:
class Win32_GroupUser : CIM_Component
{
Win32_Group REF GroupComponent;
Win32_Account REF PartComponent;
};
My vbscript is as follows:
dim objWMIService, o, obj, test, test1, strComputer
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\cimv2")
set obj = objWMIService.ExecQuery("select partcomponent,groupcomponent from win32_groupuser")
for each o in obj
set test = objWMIService.ReferencesTo(o.groupcomponent)
wscript.echo o.groupcomponent
set test1 = test.itemindex(0)
wscript.echo "test is a "&typename(test)&", test1 is a "&typename(test1)
on error resume next
for each j in test1.methods_ 'list all methods
wscript.echo "Method: "&j.name
next
for each j in test1.properties_ 'list all properties
wscript.echo "Property: "&j.name
next
i = test1.properties_("GroupComponent")
wscript.echo "Groupcomponent is a " & typename(i)
wscript.echo "GroupComponent: "&i
next
The output is
\\COMPUTER\root\cimv2:Win32_Group.Domain="TESTDOMAIN",Name="Schema Admins"
test is a SWbemObjectSet, test1 is a SWbemObjectEx
Property: GroupComponent
Property: PartComponent
Groupcomponent is a String
Groupcomponent: \\COMPUTER\root\cimv2:Win32_NTDomain.Name="Domain: TESTDOMAIN"
However I am having trouble trying to follow the reference to the GroupComponent
; it keeps on coming out as a string and not as a win32_group object, hence I cannot access the properties such as SID etc.
How do I access the groupcomponent as a win32_group object and not as the string?