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]]
Add comment