Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get Array Values from WMI Query

174 views
Skip to first unread message

Bill208

unread,
Jan 5, 2011, 2:27:33 PM1/5/11
to
Hi All,
I'm trying to figure out how to get the array values from a WMI
query. When I have a query with no array values like below I have no
issues and my code works just fine.

select Name, Availability, MaxClockSpeed, CpuStatus from
Win32_Processor

But when I try to use a query to return some array values I get an
"Invalid Query" exception, like from the query below:

select
DomainDeny[],DomainGrant[],GrantByDefault,IPDeny[],IPGrant[],Name from
IIsIPSecuritySetting

So apparently you have to handle the array data types differently. I
just can't seem to figure out how. Any thoughts on how to get this?

Thanks,
Bill

Below is my code for getting this data:

string remoteComputer = "\\\\" + _server + "\\root\\" + _wmiNamespace;
ConnectionOptions oConn = new ConnectionOptions();
oConn.Authentication = AuthenticationLevel.PacketPrivacy;
oConn.Impersonation = ImpersonationLevel.Impersonate;

ManagementScope oMS = new ManagementScope(remoteComputer, oConn);
oMS.Connect();

ObjectQuery oQuery = new System.Management.ObjectQuery(_wmiQuery);
ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(oMS,
oQuery);
ManagementObjectCollection oReturnCollection = oSearcher.Get();
foreach (ManagementObject oReturn in oReturnCollection) //Invalid
Query Exception here
{
//do stuff
}

Zinck74

unread,
Jan 5, 2011, 6:35:00 PM1/5/11
to
Nevermind, I'm an idiot. :) Even though they are listed on the MS website as being like DomainDeny[], you don't actually use the square brackets in the WMI query. I still haven't actually gotten the data out of the arrays, but I assume I will just need to loop through the array to get the data I need.
0 new messages