Search found 7 matches

by redskins1234
Thu Jan 31, 2019 3:14 pm
Forum: Nagios XI
Topic: Powershell exiting OK even with errors?
Replies: 8
Views: 1398

Re: Powershell exiting OK even with errors?

Maybe a try/catch is the best case here? This looks like the best of both worlds, we keep around $lastexitcode for when it's needed, but if the script encounters any problem starting (i.e. missing, mangled script etc), the catch will run and exit with a 3. Tested with my script and it still captures...
by redskins1234
Thu Jan 31, 2019 1:58 pm
Forum: Nagios XI
Topic: Powershell exiting OK even with errors?
Replies: 8
Views: 1398

Re: Powershell exiting OK even with errors?

That looks good to me, but quickly testing that, this wrapper isn't a catch all for a script not running at all. I.e. if the script has errors like the original post. I understand at a certain level its the responsibility of us to make sure these scripts run and are actually there, but on wide scale...
by redskins1234
Thu Jan 31, 2019 9:23 am
Forum: Nagios XI
Topic: Powershell exiting OK even with errors?
Replies: 8
Views: 1398

Re: Powershell exiting OK even with errors?

I actually wanted to test something this morning, and completely deleted the script off a server. I then forced the check, and it STILL came back okay Current Status: OK (for 4d 17h 0m 30s) Status Information: scripts\check_windows_updates.ps1 : The module 'scripts' could not be loaded. For more inf...
by redskins1234
Wed Jan 30, 2019 3:12 pm
Forum: Nagios XI
Topic: Powershell exiting OK even with errors?
Replies: 8
Views: 1398

Re: Powershell exiting OK even with errors?

Apologies for the very late response. Read your link and the error there was the wrapping, which as you said looks fine here.. The script I'm running is actually a slightly modified version of this one. None of the modifications we made change the exit code codes. https://exchange.nagios.org/directo...
by redskins1234
Tue Dec 11, 2018 2:38 pm
Forum: Nagios XI
Topic: Powershell exiting OK even with errors?
Replies: 8
Views: 1398

Powershell exiting OK even with errors?

Reposting this in the correct fourm Implementing a new script on some servers with check_nrpe!script.ps1, and made a mistake while copying it over to everyone. I had a misplaced " somewhere which caused the script to break and exit with an error. But, I noticed that this was still returning an ...
by redskins1234
Mon Dec 10, 2018 5:10 pm
Forum: Open Source Nagios Projects
Topic: Powershell Execution Policy Bypass
Replies: 4
Views: 2990

Re: Powershell Execution Policy Bypass

Hmm, looks like this does work. On some hosts it was not working so maybe it's an issue of different versions? Either way, thank you.
by redskins1234
Wed Nov 14, 2018 9:54 am
Forum: Open Source Nagios Projects
Topic: Powershell Execution Policy Bypass
Replies: 4
Views: 2990

Powershell Execution Policy Bypass

The current powershell wrapping looks like the following, and requires your execution policy to be set to remote signed. ;Powershell wrapping ps1=cmd /c echo scripts\\%SCRIPT% %ARGS%; exit($lastexitcode) | powershell.exe -command - Ideally in our environment, we do not want to open up the execution ...