What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Cannot transfer placeholders to powershell script in Execute Program notification

Votes:

0

Your Vote:

Up

Down

Hi,

1. I set up a notification using Execute Program. The Parameters is: %probe %group %device %name %sensorid %status %down %message

2. The code of powershell script:

$outfile = "C:\PRTGtoZendesk\ha.txt"
for ($i=0; $i -lt 8; $i++) {
    $newline = "hello " + $args[$i] + "`n"
    Add-Content $outfile $newline
}

3. I selected "Send test notification", then opened the file "C:\PRTGtoZendesk\ha.txt". The result was:
hello %probe

hello %group

hello %device

hello %name

hello %sensorid

hello %status

hello %down

hello %message

So my question is: how can I transfer the values of the placeholders to the powershell script ?
Thanks.

execute-program placeholders powershell

Created on Jul 24, 2020 7:36:01 AM by  songviet (50) 1 1

Last change on Jul 24, 2020 12:53:30 PM by  Moritz Heller [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

Your Vote:

Up

Down

Hi, It work now. I added single quotes to each parameter.

Created on Jul 27, 2020 7:31:28 AM by  songviet (50) 1 1



4 Replies

Votes:

0

Your Vote:

Up

Down

Hi there,

Please note that the placeholders are resolved and transmitted according to their order. Therefore, you need to configure the same amount of parameters in you script as transferred:

Notification template: %probe %group %device %name %sensorid %status %down %message
Script: $para1 $para2 .....

Afterwards, the parameters are filled with the resolved placeholders.

Created on Jul 24, 2020 12:58:13 PM by  Moritz Heller [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Hi, The problem here is the values of %probe, %group, %device, ... are not transferred to the powershell script. Instead, it transfer the string "%probe", "%group", "%device", ... to the powershell script.

E.g. it should be "hello 1234" instead of "hello %sensorid" in the text file.

Created on Jul 25, 2020 2:31:19 AM by  songviet (50) 1 1



Votes:

0

Your Vote:

Up

Down

Hi,

In this case, how do you tried to test this connection? A test notification (triggered via the bell icon in PRTG), no placeholders are translated since no real values are provided by any device or sensor. For a real test, you can configure a state trigger in one sensor and then trigger a "Simulated Error" via the context menu of the Sensor.

Created on Jul 27, 2020 5:52:41 AM by  Moritz Heller [Paessler Support]



Accepted Answer

Votes:

0

Your Vote:

Up

Down

Hi, It work now. I added single quotes to each parameter.

Created on Jul 27, 2020 7:31:28 AM by  songviet (50) 1 1



Please log in or register to enter your reply.


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.