SCCM Computer Startup Script–Part 2

 

This is part two in a three part post regarding SCCM Computer Startup Scripts and SCCM Health.

Part 1- The script itself

Part 2 – The .MOF file additions

Part 3 – The SQL query for reporting

SCCM MOF additions

Editing the SMS_DEF.MOF file isn’t too terribly hard to do.  In fact, Sherry Kissinger has many posts regarding this topic on http://myitforum.com 

However, editing the SMS_DEF.MOF to include registry keys is a bit more difficult.  In fact, if you don’t edit the SMS_DEF.MOF file correctly, you will break the Hardware Inventory Agent.  (Meaning, that once the bad .MOF file is compiled by the machine, the Hardware Inventory Agent SCCM Client Action will not be available!)

Also, you need to consider 64 bit systems along with 32 bit systems. 

Have no fear though, Sherry Kissinger has pulled through once again!  There is a tool created by Mark Cochrane that automates the editing of the SMS_DEF.MOF and Configuration.MOF files.  http://myitforum.com/cs2/blogs/skissinger/archive/2009/04/13/mark-cochrane-s-regkeytomof.aspx

Download the tool here:  http://myitforum.com/cs2/files/folders/proddocs/entry152945.aspx

Finally, here are the updates to the two files that you will need if you want to report on the status of the SCCM Health Check Script.

SMS_DEF.MOF

// RegKeyToMOF by Mark Cochrane (thanks to Skissinger, Steverac & Jonas Hettich)
// this section tells the inventory agent what to report to the server
// 1/19/2011 13:32:08

#pragma namespace (“\\\\.\\root\\cimv2\\SMS”)
#pragma deleteclass(“SCCM_Health_Check”, NOFAIL)
[SMS_Report(TRUE),SMS_Group_Name(“SCCM_Health_Check”),SMS_Class_ID(“CUSTOM|SCCM_Health_Check|1.0”),
SMS_Context_1(“__ProviderArchitecture=32|uint32”),
SMS_Context_2(“__RequiredArchitecture=true|boolean”)]
Class SCCM_Health_Check: SMS_Class_Template
{
[SMS_Report(TRUE),key] string KeyName;
[SMS_Report(TRUE)] String Scan_Run;
[SMS_Report(TRUE)] String Last_Run;
[SMS_Report(TRUE)] String CCM_Service_Check;
[SMS_Report(TRUE)] String SCCM_AssignedSite;
[SMS_Report(TRUE)] String SCCM_AutoAssignment;
[SMS_Report(TRUE)] String AdminShare_Check;
[SMS_Report(TRUE)] String Account_Check;
[SMS_Report(TRUE)] String WindowsUpdate_Service_Check;
[SMS_Report(TRUE)] String HS_CCM_Service_Check;
[SMS_Report(TRUE)] String HS_AdminShare_Check;
[SMS_Report(TRUE)] String HS_Account_Check;
[SMS_Report(TRUE)] String HS_WindowsUpdate_Service_Check;
[SMS_Report(TRUE)] String HS_SCCM_AssignedSite;
[SMS_Report(TRUE)] String HS_SCCM_AutoAssignment;
[SMS_Report(TRUE)] String CCM_Client_Check;
[SMS_Report(TRUE)] String SCCM_Install;
};

#pragma namespace (“\\\\.\\root\\cimv2\\SMS”)
#pragma deleteclass(“SCCM_Health_Check_64”, NOFAIL)
[SMS_Report(TRUE),SMS_Group_Name(“SCCM_Health_Check”),SMS_Class_ID(“CUSTOM|SCCM_Health_Check|1.0”),
SMS_Context_1(“__ProviderArchitecture=64|uint32”),
SMS_Context_2(“__RequiredArchitecture=true|boolean”)]
Class SCCM_Health_Check_64 : SMS_Class_Template
{
[SMS_Report(TRUE),key] string KeyName;
[SMS_Report(TRUE)] String Scan_Run;
[SMS_Report(TRUE)] String Last_Run;
[SMS_Report(TRUE)] String CCM_Service_Check;
[SMS_Report(TRUE)] String SCCM_AssignedSite;
[SMS_Report(TRUE)] String SCCM_AutoAssignment;
[SMS_Report(TRUE)] String AdminShare_Check;
[SMS_Report(TRUE)] String Account_Check;
[SMS_Report(TRUE)] String WindowsUpdate_Service_Check;
[SMS_Report(TRUE)] String HS_CCM_Service_Check;
[SMS_Report(TRUE)] String HS_AdminShare_Check;
[SMS_Report(TRUE)] String HS_Account_Check;
[SMS_Report(TRUE)] String HS_WindowsUpdate_Service_Check;
[SMS_Report(TRUE)] String HS_SCCM_AssignedSite;
[SMS_Report(TRUE)] String HS_SCCM_AutoAssignment;
[SMS_Report(TRUE)] String CCM_Client_Check;
[SMS_Report(TRUE)] String SCCM_Install;
};

Configuration.mof

// RegKeyToMOF by Mark Cochrane (thanks to Skissinger, Steverac & Jonas Hettich)
// this section tells the inventory agent what to collect
// 1/19/2011 13:32:08

#pragma namespace (“\\\\.\\root\\cimv2”)
#pragma deleteclass(“SCCM_Health_Check”, NOFAIL)
[DYNPROPS]
Class SCCM_Health_Check
{
[key] string KeyName;
String Scan_Run;
String Last_Run;
String CCM_Service_Check;
String SCCM_AssignedSite;
String SCCM_AutoAssignment;
String AdminShare_Check;
String Account_Check;
String WindowsUpdate_Service_Check;
String HS_CCM_Service_Check;
String HS_AdminShare_Check;
String HS_Account_Check;
String HS_WindowsUpdate_Service_Check;
String HS_SCCM_AssignedSite;
String HS_SCCM_AutoAssignment;
String CCM_Client_Check;
String SCCM_Install;
};

[DYNPROPS]
Instance of SCCM_Health_Check
{
KeyName=”RegKeyToMOF_32″;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|Scan_Run”),Dynamic,Provider(“RegPropProv”)] Scan_Run;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|Last_Run”),Dynamic,Provider(“RegPropProv”)] Last_Run;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|CCM_Service_Check”),Dynamic,Provider(“RegPropProv”)] CCM_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|SCCM_AssignedSite”),Dynamic,Provider(“RegPropProv”)] SCCM_AssignedSite;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|SCCM_AutoAssignment”),Dynamic,Provider(“RegPropProv”)] SCCM_AutoAssignment;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|AdminShare_Check”),Dynamic,Provider(“RegPropProv”)] AdminShare_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|Account_Check”),Dynamic,Provider(“RegPropProv”)] Account_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|WindowsUpdate_Service_Check”),Dynamic,Provider(“RegPropProv”)] WindowsUpdate_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_CCM_Service_Check”),Dynamic,Provider(“RegPropProv”)] HS_CCM_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_AdminShare_Check”),Dynamic,Provider(“RegPropProv”)] HS_AdminShare_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_Account_Check”),Dynamic,Provider(“RegPropProv”)] HS_Account_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_WindowsUpdate_Service_Check”),Dynamic,Provider(“RegPropProv”)] HS_WindowsUpdate_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_SCCM_AssignedSite”),Dynamic,Provider(“RegPropProv”)] HS_SCCM_AssignedSite;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_SCCM_AutoAssignment”),Dynamic,Provider(“RegPropProv”)] HS_SCCM_AutoAssignment;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|CCM_Client_Check”),Dynamic,Provider(“RegPropProv”)] CCM_Client_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|SCCM_Install”),Dynamic,Provider(“RegPropProv”)] SCCM_Install;
};

#pragma namespace (“\\\\.\\root\\cimv2”)
#pragma deleteclass(“SCCM_Health_Check_64”, NOFAIL)
[DYNPROPS]
Class SCCM_Health_Check_64
{
[key] string KeyName;
String Scan_Run;
String Last_Run;
String CCM_Service_Check;
String SCCM_AssignedSite;
String SCCM_AutoAssignment;
String AdminShare_Check;
String Account_Check;
String WindowsUpdate_Service_Check;
String HS_CCM_Service_Check;
String HS_AdminShare_Check;
String HS_Account_Check;
String HS_WindowsUpdate_Service_Check;
String HS_SCCM_AssignedSite;
String HS_SCCM_AutoAssignment;
String CCM_Client_Check;
String SCCM_Install;
};

[DYNPROPS]
Instance of SCCM_Health_Check_64
{
KeyName=”RegKeyToMOF_64″;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|Scan_Run”),Dynamic,Provider(“RegPropProv”)] Scan_Run;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|Last_Run”),Dynamic,Provider(“RegPropProv”)] Last_Run;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|CCM_Service_Check”),Dynamic,Provider(“RegPropProv”)] CCM_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|SCCM_AssignedSite”),Dynamic,Provider(“RegPropProv”)] SCCM_AssignedSite;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|SCCM_AutoAssignment”),Dynamic,Provider(“RegPropProv”)] SCCM_AutoAssignment;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|AdminShare_Check”),Dynamic,Provider(“RegPropProv”)] AdminShare_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|Account_Check”),Dynamic,Provider(“RegPropProv”)] Account_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|WindowsUpdate_Service_Check”),Dynamic,Provider(“RegPropProv”)] WindowsUpdate_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_CCM_Service_Check”),Dynamic,Provider(“RegPropProv”)] HS_CCM_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_AdminShare_Check”),Dynamic,Provider(“RegPropProv”)] HS_AdminShare_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_Account_Check”),Dynamic,Provider(“RegPropProv”)] HS_Account_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_WindowsUpdate_Service_Check”),Dynamic,Provider(“RegPropProv”)] HS_WindowsUpdate_Service_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_SCCM_AssignedSite”),Dynamic,Provider(“RegPropProv”)] HS_SCCM_AssignedSite;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|HS_SCCM_AutoAssignment”),Dynamic,Provider(“RegPropProv”)] HS_SCCM_AutoAssignment;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|CCM_Client_Check”),Dynamic,Provider(“RegPropProv”)] CCM_Client_Check;
[PropertyContext(“Local|HKEY_LOCAL_MACHINE\\SOFTWARE\\SCCM\\SCCM_Health_Check|SCCM_Install”),Dynamic,Provider(“RegPropProv”)] SCCM_Install;
};