Please where is the error?

XML: Junk after document element </channel> -- JSON: The returned JSON does not match the expected structure (No mapping for the Unicode character exists in the target multi-byte code page). (code: PE231)
<?xml version="1.0"?>
    <prtg>
    <result>
        <channel>DC01</channel>
        <unit>Custom</unit>
        <CustomUnit>min</CustomUnit>
        <mode>Absolute</mode>
        <showChart>1</showChart>
        <showTable>1</showTable>
        <float>0</float>
        <value>790</value>
        <LimitMaxError>59</LimitMaxError>
        <LimitMaxWarning>20</LimitMaxWarning>
        <LimitWarningMsg>Attenzione limite di avviso raggiunto</LimitWarningMsg>
        <LimitErrorMsg>Attenzione BBU in errore</LimitErrorMsg>
        <LimitMode>1</LimitMode>
    </result>
    <result>
        <channel>DC04</channel>
        <unit>Custom</unit>
        <CustomUnit>min</CustomUnit>
        <mode>Absolute</mode>
        <showChart>1</showChart>
        <showTable>1</showTable>
        <float>0</float>
        <value>791</value>
        <LimitMaxError>59</LimitMaxError>
        <LimitMaxWarning>20</LimitMaxWarning>
        <LimitWarningMsg>Attenzione limite di avviso raggiunto</LimitWarningMsg>
        <LimitErrorMsg>Attenzione BBU in errore</LimitErrorMsg>
        <LimitMode>1</LimitMode>
    </result>
    </prtg>

my code

$Results = Get-Content BBUSTS.TXT

$xmlstring = "<?xml version=`"1.0`"?>`n    <prtg>`n"
$xmlstring += "    <result>`n"
$xmlstring += "        <channel>$($Results.Split(" ")[0])</channel>`n"
$xmlstring += "        <unit>Custom</unit>`n"
$xmlstring += "        <CustomUnit>min</CustomUnit>`n"
$xmlstring += "        <mode>Absolute</mode>`n"
$xmlstring += "        <showChart>1</showChart>`n"
$xmlstring += "        <showTable>1</showTable>`n"
$xmlstring += "        <float>0</float>`n"
$xmlstring += "        <value>$($Results.Split(" ")[38])</value>`n"
$xmlstring += "        <LimitMaxError>59</LimitMaxError>`n"
$xmlstring += "        <LimitMaxWarning>20</LimitMaxWarning>`n"
$xmlstring += "        <LimitWarningMsg>Attenzione limite di avviso raggiunto</LimitWarningMsg>`n"
$xmlstring += "        <LimitErrorMsg>Attenzione BBU in errore</LimitErrorMsg>`n"
$xmlstring += "        <LimitMode>1</LimitMode>`n"
$xmlstring += "    </result>`n"
$xmlstring += "    <result>`n"
$xmlstring += "        <channel>$($Results.Split(" ")[220])</channel>`n"
$xmlstring += "        <unit>Custom</unit>`n"
$xmlstring += "        <CustomUnit>min</CustomUnit>`n"
$xmlstring += "        <mode>Absolute</mode>`n"
$xmlstring += "        <showChart>1</showChart>`n"
$xmlstring += "        <showTable>1</showTable>`n"
$xmlstring += "        <float>0</float>`n"
$xmlstring += "        <value>$($Results.Split(" ")[261])</value>`n"
$xmlstring += "        <LimitMaxError>59</LimitMaxError>`n"
$xmlstring += "        <LimitMaxWarning>20</LimitMaxWarning>`n"
$xmlstring += "        <LimitWarningMsg>Attenzione limite di avviso raggiunto</LimitWarningMsg>`n"
$xmlstring += "        <LimitErrorMsg>Attenzione BBU in errore</LimitErrorMsg>`n"
$xmlstring += "        <LimitMode>1</LimitMode>`n"
$xmlstring += "    </result>`n"
$xmlstring += "    </prtg>"
Write-Host $xmlstring

Article Comments

hi, there is a program or application PAESSLER that's help me to test my xml ?

Thanks


Jan, 2020 - Permalink

The output looks fine. Did you ensure that the Execution Policy is correctly configured?


Jan, 2020 - Permalink

Yesssssss set-executionpolicy -executionpolicy Unrestriced

Work Fine Thanks


Jan, 2020 - Permalink

Then you need to enable the "Write Result To Disk" option within the Sensor settings and open up C:\ProgramData\Paessler\PRTG Network Monitor\Logs\Sensors\

There should be a file with the Sensor ID in its name. Could you post that one? Make sure to remove any sensible information from the log file before doing that.


Jan, 2020 - Permalink