ps1 plugin not returning proper exit code
Posted: Tue Sep 21, 2021 12:07 pm
So, I converted all my Windows servers over to NCPA, YAY!! I wrote a new plugin using powershell and this is the bottom of the code:
No matter what happens though, NCPA is saying it is OK. Example here:
I even went on this host, modified the .ps1 to "exit 2" and NCPA still shows the above screenshot.
My Config for ps1 files in NCPA is the default settings. Any idea why this isn't returning the exit code as desired?
Code: Select all
if ( ( $days -ge $threshold ) ) {
$returnString = "CRITICAL: " + $days + " since last update"
$returnState = $returnStateCritical
} else {
$returnString = "OK: " + $days + " since last update"
$returnState = $returnStateOK
}
Write-Host $returnString
exit $returnStateMy Config for ps1 files in NCPA is the default settings. Any idea why this isn't returning the exit code as desired?