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