Share via


OpsMgr: Creating a Powershell script Collection Rule with the MP Author tool

In this post, I would like to demonstrate how a Powershell script collection rule can be configured with MP Author (https://mpauthor.com/), what to look out for, and how to make it run at a more frequent schedule

For more information on how to create a Powershell script based monitor with MP Author and making it run at a more frequent schedule, please visit my earlier blog post.

image

First. create a Powershell script collection rule using the Create New Script Performance Rule wizard:  

005

Next, on Specify Script Information page, specific the Script name, Script body, and Script Parameters:

Note:
The sample script used for this demo was a script that collects Health Service Workflow Count value from the performance monitor of an agent managed computer and returns this information in a ProprtyBag.
The target variable of the server name was specified as the input value for the script parameter. The rule will run on an agent against a particular target object and it will get the values for any target variables from that object.

b002

Then, map the data from the ProprtyBag to the performance data.

b003

Configure the target and identity for the rule, enable the rule and enable link report creation.

Note:
The target used for the demo was the single instance RMS Emulator

b004

b005

Leave the schedule information at default setting.     
    
Observation:

No option to set the schedule to a smaller interval like every few minutes instead of using a daily interval from the UI.

b006

Review summary before creating the Powershell script collection rule:

b007

After the rule is created, all settings can be viewed from the Properties View/Edit page:

b008

Clicking the Edit XML button will display the following XML definition for the collection rule:

b009

Lastly, import the MP Author created management pack into an OpsMgr management group to test the Powershell script collection rule created.

My Test Results:
1. Limited options to modify or fix collection rule settings in Operations Console rule properties:

 b012_

This is because the when creating the new Powershell script collection rule, MP Author creates a new composite data source module that runs the Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe Probe action module on a schedule.
The Powershell script that was supplied from the UI is used as the input value for the ScriptBody parameter in Probe action module of the composite data source module, hence will not appear at the XML configuration level.

image

                                                       ……..

2. Collection rule not collecting data on a frequent basis:

The scheduled interval for the collection rule can only be set to run on a daily basis. There is no way to change the scheduled interval to run at an hourly, minute or second interval through overrides or rule configuration in the Operation Consoles or in MP Author .
On further investigation, I found out that the Scheduler module of the Powershell script collection rule (from Test Result 1) was automatically configured to run on a daily basis when the collection rule was created in MP Author.
image

To allow the collection rule to run at a smaller interval, you can replace the XML definition for the Scheduler module within the rule’s composite data source module as shown above with the following definition. This allows the Powershell script collection rule to run at a 2 minute interval. Feel free to modify the IntervalSeconds value as required: 
             image After fixing the scheduled interval, the collection rule ran at a smaller scheduled interval and data was able to be collected at a more frequent basis with the new scheduler setting:

image

  

Hope this article gives you a better idea on how to configure and make this MP Author feature work for your specific performance collection and reporting scenarios.

Happy New Year !  

 

Disclaimer:  

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.