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

customexe powershell sensor problems

Votes:

0

I'm getting a malformed XML data on powershell.

This is literally all the powershell script is.

"<prtg>"
    "<result>"
    "<channel>dats</channel>"
    "<value>1</value>"
    "</result>"
"</prtg>"

Can someone please explain to me what I'm doing wrong?

Running the data through an XML validator says all is good. Powershell ISE says all is good, and the data looks like it's suppose to. I've also tried write-host and write-output in various options

Powershell on the system is version 2. PRTG is 18.4.46.1754

beginner custom-sensor powershell xml

Created on Jan 6, 2019 3:13:04 AM



3 Replies

Votes:

0

Hello Matt,

Thank you very much for your contact.

First things first, are you able to update the used Powershell version 2 to one more up to date, for instance by installing the Windows Windows Management Framework 5.1?

Best regards,
Sebastian

Created on Jan 7, 2019 12:36:08 PM by  Sebastian Kniege [Paessler Support]



Votes:

1

Here is what I normally implement in all my PowerShell scripts to generate output:

$XML = "fill this with e.g. your XML code above or what ever your script should output"

Function WriteXmlToScreen ([xml]$xml) #just to make it clean XML code...
{
    $StringWriter = New-Object System.IO.StringWriter;
    $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter;
    $XmlWriter.Formatting = "indented";
    $xml.WriteTo($XmlWriter);
    $XmlWriter.Flush();
    $StringWriter.Flush();
    Write-Output $StringWriter.ToString();
}
WriteXmlToScreen "$XML"

This will give you a 100% compatible XML response. What confused me most are all you text-marks in your example, looks odd to me.

Further - this is not a CUSTOM EXE sensor you created there, this is a advanced EXE sensor.

Your output is XML and PRTG might hick up on that, cause I think the regular EXE sensor can't process that (not sure, though, it's a LONG LONG time since I created a regular EXE sensor).

Hope this helps.

Regards

Florian Rossmark

https://www.it-admins.com|www.it-admins.com]]

Created on Jan 7, 2019 2:55:35 PM



Votes:

1

Did you already try adding the <Text> node like:

"<prtg>"
    "<result>"
    "<channel>dats</channel>"
    "<value>1</value>"
    "</result>"
    "<Text>Ok</Text>"
"</prtg>"

Sensors | Multi Channel Sensors | Tools | Notifications

Kind regards,

[[http://prtgtoolsfamily.com]] PRTGToolsFamily

Created on Jan 7, 2019 4:02:18 PM




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.