This article applies to PRTG Network Monitor 12 or later
Powershell Script for EXE/Script Sensor
Using the following script you can create an EXE/Script Sensor which is usually green, but shows an error twice a day. Attach a notification trigger to this sensor in order to test your notifications, e.g. by intentionally sending out an SMS text messages for testing.
PowerShell Script
We provide the following script without any warranty or support. Please adapt it to your needs. Thanks to Raffaele for sharing this idea with our support team!
$Time = date -f hhmm
if ($args[0] -eq $Time -or $args[1] -eq $Time) {
$msg="2:Error"
$exit=2
}else {
$msg="0:ok"
$exit=0
}
write-host $msg
exit $exit
Start Parameters
The script accepts two start parameters in which you can define the times when the sensor will show a Down status. Define them when adding your EXE/Script sensor to PRTG.
- Provide the times in hhmm 24 hours format (without a colon symbol).
- The first parameter is mandatory, the second is optional.
In the example below we provided the parameters
0700 1900
which will switch the sensor to show an error every day at 7 a.m. and 7 p.m.
See Also
Add comment