Create a Windows PowerShell script monitor in SAM
As described in PowerShell scripting in SAM component monitors, you can use the predefined Windows PowerShell Monitor create custom scripts for templates, and then assign templates to the main Orion server or remote target nodes as application monitors. After running a script, SAM processes the script's exit code and text output to display results in the Orion Web Console.
To create a script with the Windows PowerShell Monitor:
Click Settings > All Settings > SAM Settings> Manage Templates.
The Manage Application Monitor Templates page displays all available out-of-the-box and custom templates.
Search to locate, select, and edit an existing template or click Create New Template.
- Click Add Component Monitor(s) and choose Manually Add Component Monitors.
PowerShellas search text, select the Windows PowerShell Monitor, and then click add.
- Enter all arguments and parameters for the Script Arguments.
If using Remote Host as the Execution Mode, the Port Number should correlate with the TCP port used by the listener on the remote, target server. The default port for WinRM is 5986.
- Click Edit Script to enter and test the script.
Sample scripts are provided in the following default folder on the Orion server:
C:\Program Files (x86)\SolarWinds\Orion\APM\SampleScriptMonitors
Test the script by selecting settings for the output, specified node, and specified credentials. Click Get Script Output.
Output results display using the script code with success or failure and any additional notes.
Click Get Script Output to generate the output and click Save.
The metrics save to outputs to configure as part of the component monitor. These outputs display at polling intervals for the template.
- When complete, click Submit to save the template.
- Create an application monitor based on the new template and assign it to a target node. See
When tested, output generates into customizable sections. Each output section is named by the Unique ID with a Display Name you can edit. For each output, you can optionally:
- Convert the value using selected formulas.
- Configure statistic thresholds to refine alerting for the component monitor. Set the warning and critical thresholds with specific values or baseline data.
- Select a roll-up status sort option to display the best or worst status up through the template and component monitor.
- Add notes to describe the script output.
If a PowerShell script monitor causes an exception that references "SetBufferContents", see this Success Center article.