Thursday, April 9, 2015

Ping Monitor in Powershell

I wanted a basic ping monitor that could be used with Powershell, and found the following:

This function can be Dot Sourced, see my article here.

You will need to unblock the script if you downloaded it, see my article here.

You can set the notification to trigger on ping down (-NotifyOnServerDown), ping up (-NotifyOnServerBackOnline), or both (-NotifyAll).

You can set the timeout on the ping using -sleeptimeout

An example usage would be:
start-monitor -computername QLD_CPS_24 -NotifyAll -smtpserver smtp -tonotification -fromnotification

 You can take a list from a file (1 name / ip per line) using the pipeline:
get-content Monitorlist.txt | start-monitor -NotifyAll -smtpserver smtp -tonotification -fromnotification
 When the script is running, it looks like:

The up / down notifications look like:

No comments:

Post a Comment