Bill208
2011-01-05 19:27:33 UTC
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
}
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
}