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

PowerShell PRTG Advanced Custom Sensor XML output

Votes:

0

Hello,

this static ps script works as expected: {{{ $XMLResult = @" <prtg><result><channel>Server 1</channel><value>0</value></result><result><channel>Server 2</channel><value>1</value></result><result><channel>Server 3</channel><value>2</value></result></prtg> "@

Write-Host $XMLResult }}}

but I want to build the above result during runtime in a variable like this: {{{ $XMLResult = @" $myString "@

Write-Host $XMLResult }}}

or like this: {{{ $XMLResult = @" $($myString) "@

Write-Host $XMLResult }}}

The sensor shows Code: PE233 and Code: PE231error message when using a variable although the scripts have the exactly output when running from command line.

Can someone please provide an example for building channels dynamically during runtime?



Thank you in advance

advanced-custom-sensor powershell prtg

Created on Dec 15, 2022 6:04:05 PM

Last change on Dec 16, 2022 11:29:15 AM by  Moritz Heller [Paessler Support]



1 Reply

Votes:

0

Hello,

The script in this article would be a good example. You can also visit our Sensor Hub for more examples.


Kind regards,
Sasa Ignjatovic, Tech Support Team

Created on Dec 20, 2022 7:36:46 AM by  Sasa Ignjatovic [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.