miscellaneous-randomresult.ps1 - powershell script by ActiveXperts Software
miscellaneous-randomresult.ps1 returns True or False at random. Use it for testing purposes.
Use miscellaneous-randomresult.ps1 directly from ActiveXperts Network Monitor; in the Manager's 'Monitor' menu, select 'New Check (Script)' and select miscellaneous-randomresult.ps1. Configure the required parameter, or press 'Load a working sample'.
In ActiveXperts Network Monitor, Administrators can use three different scripting languages: Powershell, VBScript and SSH.
miscellaneous-randomresult.ps1 script code
#################################################################################
# ActiveXperts Network Monitor PowerShell script, © ActiveXperts Software B.V.
# For more information about ActiveXperts Network Monitor, visit the ActiveXperts
# Network Monitor web site at http://www.activexperts.com
#################################################################################
# Script
# Miscellaneous-RandomResult.ps1
# Description:
# This function returns True or False at random. Use this function for testing purposes
# Declare Parameters:
# Usage:
# .\Miscellaneous-RandomResult.ps1
# Sample:
# .\Miscellaneous-RandomResult.ps1
#################################################################################
# -- Declare Parameters
param ( )
# -- Use _activexperts.ps1 with common functions
. 'C:\Program Files\ActiveXperts\Network Monitor\Scripts\Monitor (ps1)\_activexperts.ps1'
#################################################################################
# // --- Main script ---
#################################################################################
# -- Clear screen and clear error
cls
$Error.clear()
$nRandomNumber = Get-Random -minimum 1 -maximum 10
if( $nRandomNumber -le 5 )
{
$res = 'SUCCESS:'
}
else
{
$res = 'ERROR:'
}
# -- Print script result
$res = $res + ' Random number in range [1..10]: [' + $nRandomNumber + '] DATA: ' + $nRandomNumber
echo $res
exit
#################################################################################
# // --- Catch script exceptions ---
#################################################################################
trap [Exception]
{
$res = 'UNCERTAIN: ' + $_.Exception.Message
echo $res
exit
}
