Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Introduction

Powershell is a interface for interacting with Windows systems in a scripted or automated method similar to what can be done with Bash within the Linux world.

...

This object orientated approach means that powershell also handles it's output differently then the traditional standard out/standard in conventions. From the up.time Uptime Infrastructure Monitor perspective this means we need to use a slightly different approach when triggering powershell scripts as Custom Monitors or Action Profiles. As well when using powershell scripts as custom commands via the Windows Agent.

...

One last thing to keep in mind with Powershell scripts when compared to traditional scripting languages, is that also has the idea of an 'Execution Policy', that controls what scripts or configuration files can be used. By default Powershell runs under the 'Restricted' execution Policy. For more details about Powershell's execution policys in general please refer to 'about_Execution_Policies' from Microsoft or the 'Set-ExecutionPolicy cmdlet' which allows you change these behaviours.

Monitoring Station Side: 

Obviously in order to leverage powershell scripts on your up.time Uptime Infrastructure Monitor monitoring station, it needs to be running on a Windows system. 

The first step to setting up your Powershell script for use with up.time Uptime Infrastructure Monitor is to create a simple wrapper script in batch similar to the 'mypowershell.bat' example below. The '<NUL ' at the end of the line tells the up.time Uptime Infrastructure Monitor JVM to stop waiting for more output from the ps1 script and return the contents to upUptime Infrastructure Monitor. time.  

Code Block
titlemypowershell.bat
@ECHO OFF
powershell.exe -noprofile -Command "& 'c:\uptime-scripts\backlog-monitor.ps1' " <NUL

Once you have your batch wrapper script created, you can then use the path to the .bat file in the various 'Script Name' fields within up.timeUptime Infrastructure Monitor's custom monitors or as part of Alert/Action Profiles just like you would any other script.

Agent Side:

 Setting up powershell script as custom commands for the Windows Agent is easier then the monitoring station example above, as we don't need to create the .bat wrapper script, and instead can provide the powershell.exe flags/arguments directly in the Agent Console's 'Path to Script' field. 

...