Hi,
I have a simple script with following code
$files=get-childitem "C:\Temp\test" | where {$_.extension -ne ".txt" -and $_.PSIsContainer -ne "True"} $numberfiles=$files.count if ($numberfiles -gt "4") { write-host "$numberfiles":"$numberfiles files found" exit 2 } elseif ($numberfiles -gt "0") { write-host "$numberfiles":"$numberfiles files found" exit 1 } else {write-host "no files found" exit 0 }
Basically:
- no files in directory: exit code 0, green, OK.
- more than 0 files but less or equal than 4 files in directory: exit code 1, yellow, warning.
- more than 4 files in directory: exit code 2, red, critical.
This all works, but for some reason, PRTG does not keep the value when exit code 2 is used. Only when exit code 0 or 1 is used, it keeps the value.
Screenshot: https://imgur.com/a/RMTFGER
Any ideas why this might happen?
Add comment