WMI error codes

(imported topic written by BenKus)

Hi everybody,

A question came up recently about error codes from WMI that you see in BigFix when using custom relevance to access the WMI… I put together a few notes here to assist:

80041010 – “Specified class is not valid” – Which means you are looking up a WMI class that doesn’t exist or is not implemented on your system.

q: selects “* from fake_class” of wmi
E: The expression could not be evaluated: Windows Error: unknown error 0x80041010

80041017 – “Query was not syntactically valid.” – This message will come up if you make a syntax error in your wmi query OR if you try to look up an object/attribute that doesn’t exist:

q: selects “fake from Win32_OperatingSystem” of wmi
E: The expression could not be evaluated: Windows Error: unknown error 0x80041017

80041002 – “Object cannot be found.” – Similar to the issue above, if you are using the “select object” syntax of the WMI queries and you look up an object that doesn’t exist, you will get this error.

q: property “blah” of select objects “* from Win32_OperatingSystem” of wmi
E: The expression could not be evaluated: Windows Error: unknown error 0x80041002

Hope that helps,

Ben

(imported comment written by jdgracie)

  • For the first scenario above, rather than returning the error, what would be a good way of testing if a class exists?
  • For the third scenario, rather than returning an error, how would you test if the named property exists?

Thanks,

Dave

(imported comment written by BrianPGreen)

For both cases, I think you can do something like:

(if (exists true whose (select “something from …” of wmi)) then … else …)

or you could do:

(select “something from” of wmi) | (thing to return in case of error)

(imported comment written by jdgracie)

Thanks for the quick reply, the first option works. For the sake of others having working examples to reference, I added some below

To check for a class:

Invalid class - this returns false

  • “exists true whose (if true then (exists select object “* from Win32_MissingClass” of wmi) else false)”

Valid class - this returns true

  • “exists true whose (if true then (exists select object “* from Win32_Process” of wmi) else false)”

To check for a supported/unsupported property:

Valid property - this returns true

  • “exists true whose (if true then (exists select object “Name from Win32_Process” of wmi) else false)”

Invalid property - this returns false

  • “exists true whose (if true then (exists select object “UnsupportedProperty from Win32_Process” of wmi) else false)”

(imported comment written by MBARTOSH)

I don’t know if this applies to the topic, but what about WMI being broken?

I have been using the relevance -
not exists WMI | True

This statement works in the fixlet debugger, but machines that should be relevant are not for a WMI repair fixlet. This statement used to work, but doesn’t seem to be working now.

(imported comment written by MBARTOSH)

My bad… there is nothing wrong with the statement
not exist WMI | True
. The problem is that I added the new property “Device Type” for my site criteria. Since “Device Type” uses WMI, machines with broken WMI never evaluate correctly and therefore never get into the site where the WMI repair fixlet is.

I have moved the WMI repair fixlet to the Master Action site.