andorx
(andorx)
1
Hi,
Can you give some examples for inserting multiple parameters to Community.PowerShellMonitoring.MP monitor?
I have parameters what I want to have as overridable values in my monitor:
param ($DeltaTime, $Threshold, $debugFileName)
$DeltaTime = 120 #number of minutes
$Threshold = 500 #count of objects before alerting
$debugFileName = C:\Temp\debug.txt
How can I add them all to “Parameters” box in my custom monitor and how can I use them in my script then?
2 Likes
andorx
(andorx)
2
I ask and answer by my self:)
Input to “Parameters” box this when creating the monitor/rule/task:
DeltaTime=120;Threshold=500;debugFileName=C:\Temp\debug.txt
To the script write this:
param([String]$Arguments)
Split $Arguments variable to array by semicolon
$ArgumentsArray = $Arguments -split ‘;’
Split first array value on position 0 to another array by = sign
$ArgumentsArray0Array = $ArgumentsArray[0] -split ‘=’
define integer value to $DeltaTime
$DeltaTime = [int]$ArgumentsArray0Array[1]
$ArgumentsArray1Array = $ArgumentsArray[1] -split ‘=’
$Threshold = [int]$ArgumentsArray1Array[1]
$ArgumentsArray2Array = $ArgumentsArray[2] -split ‘=’
$debugFileName = $ArgumentsArray2Array[1]
4 Likes
martin
(Martin)
3
Thanks for your answer, it helped me also…