Hi,
I made a simple script to show sensor channel in PRTG. It takes value (one number - it's change in file from 1-100) from TXT file and shows in PRTG. But I have a problem beacuse PRTG shows "0" in result.
SCRIPT:
$value = Get-Content .\TXT_File.txt Write-Host "<prtg>" "<result>" "<channel>Channel Name</channel>" "<value>$value</value>" "<mode>Absolute</mode>" "<float>0</float>" "</result>" "<text>$value</text>" "</prtg>"
When I add EXE/Script Advanced powershell script it shows "0" in PRTG sensor channel.
So I try to convert string to integer
$value = Get-Content .\TXT_file.txt $value = $value -as [int] Write-Host "<prtg>" "<result>" "<channel>Channel Name</channel>" "<value>$value</value>" "<mode>Absolute</mode>" "<float>0</float>" "</result>" "<text>$value</text>" "</prtg>"
The same result - PRTG show "0".
When I manually add value everyting works ok:
$value = 99 Write-Host "<prtg>" "<result>" "<channel>Channel Name</channel>" "<value>$value</value>" "<mode>Absolute</mode>" "<float>0</float>" "</result>" "<text>$value</text>" "</prtg>"
What I do wrong?
Thank You.
Add comment