Telegraf inputs.exec formatting - Windows powershell

Your sting looks like a valid line protocol

offsettime.stats,host=server5,protocol=ntp,source=192.168.0.100 offset=-0.0011111111 16040448399870809

In order to test what’s wrong return a static string, like the one above, or even a simpler one, also remember that exec uses cmd to call powershell, and sometimes this causes issues

To test the script call it from cmd manually powershell -file _fileName_ or powershell -command _fileName_. there is a difference between the two, but it has been a while since I did some scripts and I don’t remember it.
I’ve had some problems in the past and ended up using Write-Output instead of Write-Host because in some cases cmd was “losing” characters.

To ensure what’s being outputted to influxDB you can also set up an output file in order to have the actual line protocol strings you are producing

here are some older posts about PowerShell that might help you:

1 Like