Having issue with sending powershell a variable.

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Having issue with sending powershell a variable.

Post by JohnFLi »

I am trying to run a powershell command to a windows box using NRPE

my nsclient.ini i have:

Code: Select all

check_updates=cmd /c echo scripts\Check-Updates.ps1 $ARG1$; exit $LastExitCode | powershell.exe -command -
at the command line of the XI server is enter:

Code: Select all

./check_nrpe -H g1vpskparc01 -t 120 -c check_updates 33
the output I get is:

Code: Select all

'GracePeriod'. Cannot convert value "$" to type "System.Int32". Error: "Input
string was not in a correct format."
At C:\Program Files\NSClient++\scripts\Check-Updates.ps1:92 char:33
+     $UpdateTime = Check-LastUpdate $GracePeriod
+                                    ~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Check-LastUpdate], ParameterBi
   ndingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Check-LastU
   pdate
In trying to figure this out, at the very begging of the powershell i have:

Code: Select all

param($warn)
$output1 = $warn | out-file c:\scripts\grace.txt
that way I can see what value is being passed.
and instead of the number 33, it is passing and single $ sign

I have retyped the ini line many times in thinking that maybe a hidden character had gotten there some how..... and no luck

Can you see what boneheaded thing i did??
Everybody is somebody else’s weirdo
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Having issue with sending powershell a variable.

Post by ssax »

Please try this:

Code: Select all

./check_nrpe -H g1vpskparc01 -t 120 -c check_updates -a 33
Thank you
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Having issue with sending powershell a variable.

Post by JohnFLi »

I knew I was being a bonehead somewhere.

Thank worked, thank you. (I could have sworn i tried the -a before. grrrrr)
Everybody is somebody else’s weirdo
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: Having issue with sending powershell a variable.

Post by dwhitfield »

It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
User avatar
JohnFLi
Posts: 559
Joined: Mon Jun 17, 2013 3:11 pm

Re: Having issue with sending powershell a variable.

Post by JohnFLi »

ah yes, close this please
Everybody is somebody else’s weirdo
Locked