OpsMgr: Creating a Powershell-based data source module for Rules

Creating a data source module that will allow any Powershell script to be included in a custom rule's workflow.
(Note: This article was written back in 2012 for OpsMgr 2007 R2 and is reposted to this MSDN blog. )

I would like to share my experience on creating a custom module in OpsMgr that will take a Powershell script and its parameters as its values, and run the script according to a schedule. This module can then be selected as a data source module in a custom rule for a Powershell script to be tested or used.

Here is a summary on how this data source module was created and configured in the OpsMgr 2007 Authoring Console:

  1. Under the type library pane, a new Data Source module was created, with ID and Display Name as follows:

  2. The Configuration Schema was configured by following the exact same configuration as the Configuration Schema in the "Microsoft.Windows.PowershellPropertyBagTriggerOnlyProbe" probe action module.


  3. Under Member Modules, the "Microsoft.Windows.PowershellPropertyBagTriggerOnlyProbe" probe action and "System.SimpleScheduler" data source modules were selected with the following IDs (Scheduler & Probe):

    Probe was configured to run in response to Scheduler according to a schedule and have parameters that will accept values from a custom rule.

  4. For Scheduler, the System.SimpleScheduler module was selected. The value for the IntervalSeconds and SyncTime parameters was configured as follows:
    These values specify how often the scheduler is going to send a trigger to the probe module.

  5. When prompted for the required parameters and optional parameters for the Probe Action Module, the following parameters were added by editing the XML.

  6. When the modules have all been added, the order they run in was defined. Scheduler was set to run first followed by Probe and it's next module was set to module output.

  7. Overridable parameters were specified:

  8. The output type of the data source module was correctly set to System.PropertyBagData.        

  9. Lastly, the data source module was saved and its management pack was then sealed (Take.A.Wei.MP.Demo.Library.MP), to allow referencing by other management packs as a library pack.

With this custom module created, a custom rule can be created to collect the data from a Powershell script to a condition detection module that will send the data to a alert generating write action module for an alert to be generated and seen in the OpsMgr Operations Console. 
Sample MP attached.

To use this custom module for a monitor, a custom monitor type will need to be created.    
Note that separate workflows for each health state will have to be defined for the monitor type. 
This module can be used as the data source module for the regular detection of the monitor type but an addition probe action module will have to be created for on demand detection.


All information on this blog is provided on an as-is basis with no warranties and for informational purposes only. Use at your own risk. The opinions and views expressed in this blog are those of the author and do not necessarily state or reflect those of my employer.