Really simple issue and fix. When returning a single result through this tool, PRTG reports en error parsing the JSON.
What happens is that when using the pipeline to feed ConvertTo-Json, even if the object passed is an array, the function only receives a single item. Because of that, ConvertTo-Json doesn't output brackets [ ] in the output, whichi PRTG requires even for a single item.
To fix this, instead of using "$this.Channels | ConvertTo-Json", the script should use "ConvertTo-Json @($this.Channels)", which forces the value to be treated as an array and always outputting the brackets [ ].
Hi,
Really simple issue and fix. When returning a single result through this tool, PRTG reports en error parsing the JSON.
What happens is that when using the pipeline to feed ConvertTo-Json, even if the object passed is an array, the function only receives a single item. Because of that, ConvertTo-Json doesn't output brackets [ ] in the output, whichi PRTG requires even for a single item.
To fix this, instead of using "$this.Channels | ConvertTo-Json", the script should use "ConvertTo-Json @($this.Channels)", which forces the value to be treated as an array and always outputting the brackets [ ].
And that makes PRTG really happy.