I currently have an issue with my notification script, when the sensor message has a single quote in it.
I'm running a PowerShell script to automatically create a ticket. The parameters for running the script: '%sensor' '%sensorid' '%status' '%message' '%device' '%since' '%lastup' '' '' '' '%prio'
All goes well, as long as the sensor message doesn't contain a quote. However, as soon as it contains a quote like "Error by lookup value 'Critical (2)' in channel 'Drum Unit' (Ready)" (a channel of the default SNMP printer settings sensor in PRTG), it breaks my script. The parameters following the '%message' parameter all get jumbled up.
It considers the single quote as a parameter. So: %message becomes "Error by lookup value" %device becomes "Critical" %since becomes "2" %lastup becomes "in channel" %prio becomes NULL (because of the 3 empty inputs, due to the structure of the PowerShell script)
I know I can kinda work around this by putting the '%message' parameter as last parameter, but that means I won't get the entire message in my ticket. So, no proper solution. This has either has to be a change in PRTG (not insert single quote in the sensor message), or a change in the way I pass the parameters to the script (but I have no idea how)...
Add comment