For those that have used RegKeyToMof to create custom inventory MOF files to inventory registry keys, or export a mof from one environment and import them into another know that it is a fairly easy to do process. I have now seen on a few occasions now where the MOF file fails to import. No matter what you do, it will not import. You receive the following error:
The MOF file you tried to import could not be compiled. Ensure that the MOF file contains valid data. You can use the command line mofcomp utility to test the data.
I have seen this issue come up a few times now and find very little information to troubleshoot it. You can run mofcomp against the MOF file, as it suggests, and find nothing wrong with the MOF file. How it initially happens isn't completely known to me either but, here is how we solved it.
So, the easy solution is to rename your Class in RegKeyToMof but, that not always the best solution because, maybe you already have custom reports and scripts that will rely on the class name. Not to mention, you just want it to be called what you first called it. :-)
The solution involves deleting temp instances of the inventory class from WMI. We used wbemtest to explore and edit WMI.
- From the server, open up an Elevated/Administrator command prompt. In the elevated prompt, type wbemtest and press enter.
- In wbemtest, click Connect.
- Enter root\cimv2\sms\inv_temp for the namespace and click Connect.
- Click Enum Classes...
- Leave Superclass name blank and click OK.
- Delete any classes that do not start with CIM_ or __ (2 underscores).
- When all are deleted, the results should look something like this:
- Exit out of Wbemtest.
Now, go back into the CM console and, in your default client settings, import the class. You should have no issues.
apparently "Delete any classes that do not start with CIM_ or __ (2 underscores)."
should also include "or SMS"
because you show "SMS_Class_Template" in the results screenshot.
Guess which one I deleted in step 6 since it was absent in the text and even highlighted in the screenshot. ¯\_(ツ)_/¯
SMS_Class_Template should also be able to be deleted as well. I just missed it in my example screens.
Worked well for me. Amazing solution!