Hello, I have a powershell script for monitoring the windows firewall :
if (((Get-NetFirewallProfile | select name,enabled) | where { $_.Enabled -eq $True } | measure ).Count -eq 3) {exit 0} else {exit 2}
In nsclient.ini I have :
check_fw_state=cmd /c echo scripts\\custom\\check_fw_state.ps1; exit($lastexitcode) | powershell.exe -command -
When I launch it I have this :
PS C:\Program Files\Centreon NSClient++\scripts\custom> .\check_fw_state.ps1
PS C:\Program Files\Centreon NSClient++\scripts\custom> $LASTEXITCODE
2
But when I try with nscp test I have this :
check_fw_state
D ext-script Command line: cmd /c echo scripts\\custom\\check_fw_state.ps1; exit($lastexitcode) | powershell.exe -comma
d -
L cli CRITICAL: No output available from command (check_fw_state).
L cli Performance data:
What do I miss ?
NB: If I put a Write-Host “2”instead of “exit 2” I get the return but it’s not a critical :
check_fw_state
D ext-script Command line: cmd /c echo scripts\\custom\\check_fw_state.ps1; exit($lastexitcode) | powershell.exe -comman
d -
L cli OK: 2
L cli Performance data: