Tag Archives: MimboloveHardware Inventory
Download: MOF Extension for OpsMgr Configurations
I’ve been wanting to do this for a while now and finally found some spare time for it. I want to be able to target OpsMgr (SCOM) agents and servers in ConfigMgr (SCCM) in a more granular way (i.e. all OpsMgr agents that are reporting to a OpsMgr Management Server, or all OpsMgr agents within a OpsMgr management group or All OpsMgr management servers)
Therefore, I created these extensions for configuration.mof and sms_def.mof so OpsMgr settings are captured as part of ConfigMgr client hardware inventory.
Once loaded in to ConfigMgr and after clients have retrieved new policy and performed hardware inventory, you will be able to see this in Resource Explorer:
For OpsMgr Agents:
For OpsMgr Servers:
Note: As always, make sure backup both mof files before editing them. once saved, monitor dataldr.log to make sure they are successfully compiled.
Please refer to my previous blog if you decide to remove this mof extention from your ConfigMgr environment.
More Reading about ConfigMgr Hinv (Hardware Inventory):
Collection Query Samples:
All OpsMgr agents in Management Group TYANG:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_CUSTOM_OPSMGR_2007_AGENT_SETTING_2_0 on SMS_G_System_CUSTOM_OPSMGR_2007_AGENT_SETTING_2_0.ResourceId = SMS_R_System.ResourceId where SMS_G_System_CUSTOM_OPSMGR_2007_AGENT_SETTING_2_0.ManagementGroup = "TYANG"
All OpsMgr agents managed by OpsMgr Management Server SCOM02:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_CUSTOM_OPSMGR_2007_AGENT_SETTING_2_0 on SMS_G_System_CUSTOM_OPSMGR_2007_AGENT_SETTING_2_0.ResourceId = SMS_R_System.ResourceId where SMS_G_System_CUSTOM_OPSMGR_2007_AGENT_SETTING_2_0.ManagementServer = "SCOM02.corp.tyang.org"
All OpsMgr Management Servers:
select * from SMS_R_System inner join SMS_G_System_CUSTOM_OPSMGR_2007_SERVER_SETTING_2_0 on SMS_G_System_CUSTOM_OPSMGR_2007_SERVER_SETTING_2_0.ResourceId = SMS_R_System.ResourceId where SMS_G_System_CUSTOM_OPSMGR_2007_SERVER_SETTING_2_0.IsServer = 1
In SCCM, after removing WMI classes that are no longer required from configuration.mof and sms_def.mof, the inventory data still exists in few places.
If you decide to clean them up, MyITForum.com has a great WIKI page for SCCM hardware inventory which talked about different ways to clean up hardware inventory data.
I have tried the free SiteSweeper tool from SCCMExpert.com which was mentioned in the WIKI page. It’s easy to use and you can remove multiple classes from site database at once:
Other than removing the data from site databases throughout the hierarchy, the WMI class which you defined in the configuration.mof still exists in the client. I didn’t bother to look further to find tools/utilities to delete WMI classes, but simple found a sample vbscript from MSDN to modify WMI classes, and modified a little bit:
wbemCimtypeString = 8 ' String datatype Set objSWbemService = GetObject("Winmgmts:root\cimv2") Set objClass = objSWbemService.Get() objClass.Path_.Class = "<name of WMI class you wish to delete>" ' Remove the new class and instance from the repository objClass.Delete_() If Err <> 0 Then WScript.Echo Err.Number & " " & Err.Description Else WScript.Echo "Delete succeeded" End If ' Release SwbemServices object Set objSWbemService = Nothing
To modify it, specify the WMI class you wish to delete on line 4. If the WMI class is not located in root\CIMV2 namespace, change line 2 as well.
I created a package in SCCM and advertised it to all systems.
Note: When you create the program, make sure you use the syntax “Cscript DeleteWMIClass.vbs” so the output is redirected to command prompt rather than a message box.
I’ve been playing with SCCM mof files this weekend. After I’ve extended configuration.mof and sms_def.mof files to inventory a registry key during hardware inventory, I noticed below error logged in InventoryAgent.log on SCCM client:
Unknown error encountered processing an instance of class <name of the WMI class>: 80041001
I checked the SCCM client, the WMI class was created correctly, but the inventory data was not loaded in the SCCM database therefore I could not view it in Resource Manager.
After gone through both configuration.mof and sms_def.mof many times made sure they are 100% correct, I found this error is actually caused by a bug in SCCM 2007.
Because the SCCM client I’m using for testing is a Windows 2008 R2 machine (therefore 64 bit) and the issue with 64 bit client is documented here.
Also, while I was playing with mof files, I found this awesome tool called RegKeyToMOF. The current version is v3.0 and can be found here. It supports SMS 2003, SCCM 2007 and SCCM 2012 Beta 2.
it automatically generates mof extensions for you when you select the registry key that you want to inventory:
If you are planning to use this tool to generate the configuration.mof and sms_def.mof extensions, please make sure you tick “Enable 64bits (for Regkeys not written in Wow6432Node)” if you have 64-bit SCCM clients in your environment (nowadays, I can’t imagine that you don’t!). This is also what above mentioned KB article suggested.