So I often create a bunch of rules that run various Powershell scripts for different tasks. Not rocket science really but here is what I do. I use the execute the Command rule as I like to have a script working directory on the RMS server with the various scripts in. In addition I use the Drive that where possible is a cluster resource so that the scripts are available to the RMS whichever is the active node.

So here is one I did for a Script for resetting health state for some Manual Rest Monitors with the Name starting with SEH * .

RMS Cluster with E: drive as a clustered resource and Script name to run is Reset-SEHMonitors.ps1

Authoring Console.

Crate a ‘Timed Commands’ Rule and give it a name and store in your Un-Sealed MP. (Obviously different if you are creating your own sealed MP) I have name mine ‘SEH Manual Reset Monitor Task’ and stored it in MP named ‘INF SEH PrintServer’ which is unsealed.

Whack a description in and Target the ‘Root Management Server’ class since this is where the Script will be executed from. I leave my rule as un-checked for Enabled as I find it is better practice especially where scripts are executed.

The schedule on the next screen is of course yopu choosing. I am running this every 15 minutes as for reasons too dull to explain.

So we will use Powershell to execute the powershell script 🙂 which is %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe

2 Responses to How to Run a Powershell Script as a rule in SCOM as a Command

Question as to Syntax when passing parameters to a powershell script from SCOM2012 – is there a reference guide somewhere for this? i want to pass the server name that’s reporting say a full event log – then run a powershell script against that server to backup & clear the event log.

Would the following be correct? my concern is the placement of the single quotes: