One of the most complicated things that an SMS Technician will find himself/herself involved with is making modifications to the SMS_DEF.MOF.
With SMS SP3, I found myself like every other SMS Technician trying to wrap my mind around the vast changes in the SP3 MOF.
This time I got lost in the changes and the customizations that I needed to make for use in our environment. I am a programmer at heart, so I look for ways to modularize my work and found myself wishing for a way to modularize the SMS_DEF.MOF changes.
I have found that debugging the modifications to the original SMS_DEF.MOF has left me lost as to what was the original and what was my changes. Then when there is a problem with something I have changed, I have to go back to a backup file, find the change and reverse that change and hopefully that fixed the problem.
This needed to be simplified for me, modularized. So what you see below is my "Compilation process" for making changes to the SMS_DEF.MOF.
The basic process is a batch file that steps out the build process and a vbscript for making strategic modifications to the final compiled SMS_DEF.MOF.
I put this entire process into a folder for compiling, this is the process for setting up this structure.
-
Rename the SMS SP3 SMS_DEF.MOF to sms_defSP3Orig.mof
-
Put all new tables into sms_def_CustomAdditions.mof
-
Extract the contents of the ZIP file to the folder (contains my MOF_C_FileChanger.vbs and a couple of .ccf files and a compile.cmd)
-
Make changes to the compile.cmd to add in Customization Change File tweaks ( the acronym for the .CCF files)
The compile.cmd when run will copy together the SMS_defSP3Orig.mof and SMS_def_CustomAdditions.mof into sms_def.mof and then using the MOF_C_FileChanger script, processes each Customization Change.
Here is an example of a basic compile.cmd file;
@echo off
Echo Copying sms_defSP3Orig.mof + sms_def_CustomAdditions.mof + SMS_def_Script.mof to sms_def.mof
copy sms_defSP3Orig.mof /A + sms_def_CustomAdditions.mof /A + SMS_def_Script.mof /A sms_def.mof
echo Compiling MOF_C_Changes.CCF
cscript.exe //Nologo MOF_C_FileChanger.vbs sms_def.mof MOF_C_Changes.CCF
Now your thinking.... what is the script doing with the control file? The script is basicly doing a block change. (the entire BLOCK MUST MATCH exactly with all spaces for it to be found and replaced) Anything between the line that starts with [[ORIGINAL BEGIN]] and [[ORIGINAL END]] is replaced with the block contents between [[REPLACEMENT BEGIN]] and [[REPLACEMENT END]]. Example; (here is the contents of the MOF_C_Changes.CCF file;
NOTE: The indent is used here for ease of reading and is NOT in the MOF_C_Changes.CCF file.
[[ORIGINAL BEGIN]]
//==================================================================
//
// SMS_DEF.mof - Maps SMS inventoriable set to that provided by
// the WBEM CIMV2 Win32 Provider - version 1085
//
// Copyright (c) Microsoft Corporation, All Rights Reserved
//
//==================================================================
//==================================================================
[[ORIGINAL END]]
[[REPLACEMENT BEGIN]]
//==================================================================
//
// SMS_DEF.mof - Maps SMS inventoriable set to that provided by
// the WBEM CIMV2 Win32 Provider - version 1085
//
// Copyright (c) Microsoft Corporation, All Rights Reserved
//
//==================================================================
//
// *****************************************************************
// ***** This MOF was compiled with MOF_C_FileChanger changes *****
// ***** Please see end of document for changes details *****
// *****************************************************************
//
//==================================================================
[[REPLACEMENT END]]
You can string together as many changes as you like. For instance, in my environment, I made a change to the Hosting Model in the AAInstProv to fix a problem with the SMS_DEF.MOF file being compiled on a Vista workstation.
Add this to the compile.cmd
echo Compiling MOF_C_AAInstProv_HostingModel.ccf
cscript.exe //Nologo MOF_C_FileChanger.vbs sms_def.mof MOF_C_AAInstProv_HostingModel.ccf
MOF_C_AAInstProv_HostingModel.ccf
[[ORIGINAL BEGIN]]
instance of __Win32Provider as $AAInstProv
{
Name = "AAInstProv" ;
ClsId = "{86875FDD-EB5D-4742-8026-94B2E31E1AB9}";
ImpersonationLevel = 1;
PerUserInitialization = "False";
};
[[ORIGINAL END]]
[[REPLACEMENT BEGIN]]
//
// Customization adjustment by Rick Jones
// Added HostingModel for Vista support.
//(NOTE: Will not compile on Windows 2000)
//
instance of __Win32Provider as $AAInstProv
{
Name = "AAInstProv" ;
ClsId = "{86875FDD-EB5D-4742-8026-94B2E31E1AB9}";
ImpersonationLevel = 1;
PerUserInitialization = "False";
HostingModel = "LocalSystemHost:SMS";
};
[[REPLACEMENT END]]
What about if you wanted to turn off reporting of some table?
Add this to the compile.cmd
echo Compiling MOF_C_AAInstProv_DisableInstalledSoftware.ccf
cscript.exe //Nologo MOF_C_FileChanger.vbs sms_def.mof MOF_C_AAInstProv_DisableInstalledSoftware.ccf
MOF_C_AAInstProv_DisableInstalledSoftware.ccf
[[ORIGINAL BEGIN]]
[ dynamic, provider("AAInstProv"),
SMS_Report (TRUE),
SMS_Group_Name ("Installed Software"),
SMS_Namespace (TRUE),
SMS_Class_ID ("MICROSOFT|INSTALLED_SOFTWARE|1.0") ]
[[ORIGINAL END]]
[[REPLACEMENT BEGIN]]
//
// Customization adjustment by Rick Jones
// Disabled Reporting
//
[ dynamic, provider("AAInstProv"),
SMS_Report (FALSE),
SMS_Group_Name ("Installed Software"),
SMS_Namespace (TRUE),
SMS_Class_ID ("MICROSOFT|INSTALLED_SOFTWARE|1.0") ]
[[REPLACEMENT END]]
This ZIP file is a working basic structure of the compiler including the script and the MOF_C_Changes.ccf file.
MOF_Compiler.zip
This is an updated version for use with ConfigMgr.
MOFCompiler_ConfigMgr.zip