I have a script that is used with the EXE/Script Advanced Sensor. If I let it run manually, it gives me a correct looking XML answer.
<prtg> <result> <channel>PasswordSyncStatus</channel> <value>1</value> </result> <result> <channel>LastDirSync</channel> <value>16.8841946583333</value> <float>1</float> </result> <result> <channel>LastPWSync</channel> <value>23.9675279916667</value> <float>1</float> </result> <result> <channel>SyncedUser</channel> <value>121</value> </result> </prtg>
But PRTG keeps saying, that it is malformated.
Error: XML: The returned XML does not match the expected schema. (code: PE233) -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)
I have no idea, what's wrong with it.
Article Comments
I tried with both, but it didn't help.
This is how teh output is created.
# Results for PRTG Sensor with Channels $XML = "<prtg>" $XML += "<result><channel>PasswordSyncStatus</channel><value>$PasswordSync</value></result>" $XML += "<result><channel>LastDirSync</channel><value>$DirSync</value><float>1</float></result>" $XML += "<result><channel>LastPWSync</channel><value>$PWSync</value><float>1</float></result>" $XML += "<result><channel>SyncedUser</channel><value>$SyncedUser</value></result>" $XML += "<result><channel>SyncedGroup</channel><value>$SyncedGroups</value></result>" $XML += "<result><channel>ServicePrincipalPasswordTimer</channel><value>$SP_PRTG_Monitoring_Days_left</value></result>" $XML += "</prtg>" #Just to make it clean XML code Function WriteXmlToScreen ([xml]$xml) { $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" write-output "$XML"
Dec, 2021 - Permalink
Hi Joerg,
I tried to recreate the output with your script and with write-output
I got no XML formatted output. You will need to change $XML so that there is a XML formatted output.
Kind regards
Felix Wiesneth - Team Tech Support
Dec, 2021 - Permalink
Hi Joerg,
From first look your output seems to be fine. Did you use
write-host
to get this result? Please try to usewrite-output
since we did some security changes and thereforewrite-host
won't work anymore.Kind regards
Felix Wiesneth - Team Tech Support
Dec, 2021 - Permalink