The command (ps1) returned an invalid return code: -196608

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

The command (ps1) returned an invalid return code: -196608

Post by arvmanya »

Hi,

I downloaded Nagios Core and setup a server (on ubuntu 14.04) and did monitor Windows machines (Win 8.1 and 2008 R2). I am facing an issue in calling powershell script from server to client. Installed NSClient on the windows machines and added all servers details in the server windows.cfg file, also added command definitions in the commands.cfg file.

While executing powershell scripts from server, I am getting below response :

The command (ps1) returned an invalid return code: -196608

NSCLIENT external scripts section-
[/settings/external scripts/scripts]
ps1 = cmd /c echo scripts\\test1 %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -File -command -

I checked configuration, both server and client side, did not find any issues with configuration. If I remove script from the script location(on client), I am getting response as Unknown command, which is correct. I checked port 5666 as well and it is listening commands from server.

Could you please help me to figure out why it is happening and what would be the resolution for this problem.

Regards,
Arvind
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: The command (ps1) returned an invalid return code: -1966

Post by rhassing »

Can you try to run the command from the commandline on the ubuntu server?
Rob Hassing
Image
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

Re: The command (ps1) returned an invalid return code: -1966

Post by arvmanya »

Hey rhassing, I ran these command command line from server only(using 'check_nrpe' within 'libexec' folder). I also tried to run it from NSCP client as well on client machine, getting the same result.
But if I ran the powershell script command line, they are working fine.

Within NSCP, I can see connections from server and command execution as well, same result, return code -196608.
arvmanya
Posts: 10
Joined: Mon Feb 29, 2016 12:00 pm

Re: The command (ps1) returned an invalid return code: -1966

Post by arvmanya »

Hi Rob,

I figured it out, I removed '-ExecutionPolicy ByPass -File' within external script section.

ps1 = cmd /c echo scripts\\test1 %ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -File -command -

I was bypassing the execution policy instead of setting it to 'RemoteSigned' but it didn't work.
Set ExecutionPolicy as 'RemoteSigned' and re-ran the scripts from server and nscp test, working fine.

Regards,
Arvind
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: The command (ps1) returned an invalid return code: -1966

Post by bwallace »

Arvind, thanks for posting the solution, hopefully that will be helpful for others down the line and also thanks rhassing. I'll go ahead and lock this thread now.
Be sure to check out the Knowledgebase for helpful articles and solutions!
Locked