I'm running a WQL query in VBScript to pull data from our SCCM database. I can do other queries that all work as expected. They usually return an object collection that I can loop through and access using the standard method:
For Each objGroup in colGroups
wscript.echo objgroup.name
Next
when using the the objgroup.GetObjectText_
method to display the data within one of the collection objects in a working query, I typically see something like:
instance of SMS_R_UserGroup
{
Name = "whatevername";
UsergroupName = "whatever";
WindowsNTDomain = "whatever";
};
There is essentially a single instance (please correct me if my terminology is wrong) within each object with properties that I can easily access.
With the problematic query, I'm seeing multiple instances within each object:
instance of __GENERIC
{
SMS_G_System_NETWORK_ADAPTER_CONFIGURATION =
instance of SMS_G_System_NETWORK_ADAPTER_CONFIGURATION
{
DefaultIPGateway = "xxxx";
DHCPEnabled = 1;
DHCPServer = "xxxx";
DNSDomain = "xxxx";
DNSHostName = "xxxx";
GroupID = 4;
Index = 9;
IPAddress = "xxxxxx";
IPEnabled = 1;
IPSubnet = "xxxx";
MACAddress = "xxxx";
ResourceID = 74762;
RevisionID = 11;
ServiceName = "xxxxxx";
TimeStamp = "xxxxx";
};
SMS_R_System =
instance of SMS_R_System
{
Active = 1;
ADSiteName = "xxxxxx";
AgentName = {"xxxxxx"};
AgentSite = {"xxxxx"};
AgentTime = {"xxxxxx"};
AlwaysInternet = 0;
Client = 1;
ClientType = 1;
ClientVersion = "xxxx";
};
How do I access the properties in an object with multiple instances? Why is it returning multiple instances?
By the way, here is the query I'm running:
SELECT *
FROM SMS_R_System
JOIN SMS_G_System_NETWORK_ADAPTER_CONFIGURATION ON
SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.ResourceID = SMS_R_System.ResourceID
WHERE SMS_R_System.Name = 'xxxxxx' AND
SMS_G_System_NETWORK_ADAPTER_CONFIGURATION.IPAddress IS NOT NULL
You're JOIN'ing SMS_R_System and SMS_G_System_NETWORK_ADAPTER_CONFIGURATION. This will yield one record for each NIC config. If the device has multiple NICs (including virtual ones) with non-null IP addresses (which could include private networks), you will get one JOIN'ed record for each. You should be able to see differences in NIC data for each "duplicate" record.