The sample management pack that provides a wizard to create PowerShell script based monitors in the Operations Console was recently updated with the ability to specify script parameters and to apply an Override to modify the script parameter value for the custom PowerShell based monitor that it can create.
For more information, check out my earlier post: New Sample Wizard to Create PowerShell Monitors in the Ops Console
This sample management pack can be downloaded from the TechNet Gallery.
Mr. Ken Hamilton posted a comment in my previous post providing a PowerUser Tip on how to get around the single overrideable parameter limit using a delimited string and a Scriptblock. This is a brilliant idea as multiple variable-value pairs can be assigned to $Arguments as a ";" delimited string and then convert that into variables within the script with a single command using a PowerShell Scriptblock.
The picture below shows how this can be done by assigning the $Argument variable to a Scriptblock and using the call operator "." to run it and create the variables.
The picture below demonstrates how this idea can be applied to a PowerShell-based monitor that uses the script parameters feature and created from the custom wizard.
The failing condition for the monitor is when the length of the string value of $ResultStr (which is a combination of values of all the variables created from the Scriptblock) exceeds 3 characters. If this condition is met, change the monitor state to Critical/Warning, else monitor state is Healthy):
Here is the state change as a result of the total length of the string value of $ResultStr exceeds the threshold of 3 characters.
As shown below, the output string (in the MessageText PropertyBag) is a combination of values of all the variables created from the “;” delimited string specified in the Parameters page of the monitor configuration, and retrieved from the $Argument variable as a parameter in the script.
The picture below demonstrates how an override can be applied to the monitor for the a specific object to override the Arguments parameter with a different “;” delimited string value on the Override page:
As a result, the new monitor state change shows that the new output string (in the MessageText PropertyBag) is a combination of values of all the variables created from the “;” delimited string specified in the Overrides page of the monitor for the specific object, and is different from the string specified in the monitor configuration.
Thanks for sharing this Ken !