Page 1 of 1

Having issue with sending powershell a variable.

Posted: Thu May 25, 2017 1:44 pm
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??

Re: Having issue with sending powershell a variable.

Posted: Thu May 25, 2017 3:51 pm
by ssax
Please try this:

Code: Select all

./check_nrpe -H g1vpskparc01 -t 120 -c check_updates -a 33
Thank you

Re: Having issue with sending powershell a variable.

Posted: Fri May 26, 2017 10:15 am
by JohnFLi
I knew I was being a bonehead somewhere.

Thank worked, thank you. (I could have sworn i tried the -a before. grrrrr)

Re: Having issue with sending powershell a variable.

Posted: Fri May 26, 2017 10:23 am
by dwhitfield
It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!

Re: Having issue with sending powershell a variable.

Posted: Tue Jun 20, 2017 3:19 pm
by JohnFLi
ah yes, close this please