What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags

View all Tags

How can I pass %message correctly to a custom notification script




I've wrote a custom notification script with PowerShell and want to pass the %message placeholder as a parameter. Unfortunately the message may contain single or double quotes. This depends on the message from PRTG itself.

My problem now is: If I pass the parameter wrapped in single quotes and the message (resolved by %message placeholder) contains a single quote itself, the string passed will be terminated too early and the script will fail, as it treats the rest of the message string as parameters or else... (Same thing with wrapping the string with double quotes and message contains a " itself...)



The message resolved by PRTGs %message placeholder: You can see, that the resolved placeholder "%message" contains single quotes and even #.

Warning caused by lookup value 'Unable to check revocation status' in channel 'Revoked' - -121 # (Days to Expiration) is below ...

So if I call my script with the following parameter line...

-prtgMessage '%message'

...it will be expanded to...

-prtgMessage 'Warning caused by lookup value 'Unable to check revocation status' in channel 'Revoked' - -121 # (Days to Expiration) is below...'

...resulting in that PowerShell parses the parameter -prtgMessage until the first single quote of the message and treat the following text as a another parameter.

I know I can wrap the placeholder in double quotes and the example will work here. BUT: I have seen other messages that contain double quotes in the text aswell, so the problem persists.

So how can I pass the %message placeholder as a parameter correctly to PowerShell, so my notification script will work reliably?


custom-notification exe notifications placeholder powershell prtg

Created on Nov 1, 2022 12:58:57 PM

2 Replies



Ok, so meanwhile I found out that others have this problem aswell. https://kb.paessler.com/en/topic/90453-single-quotes-in-message-break-notification-script

The suggestion to make the the custom sensors "Set placeholders as environment values" option available for notification scripts, too, would be a great feature.

But if you have any other suggestions, please let me know.

Created on Nov 1, 2022 3:31:45 PM




you are right, this is a know issue.

For the foreseeable future, environment variables are not planned for Exe notifications because other features are in much higher demand.

Workarounds exist, one of them being to query the lastmessage value through the PRTG API. As alternative you might want to use a string array for the powershell parameter.

Created on Nov 3, 2022 1:11:03 PM by  Arne Seifert [Paessler Support]

Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.