External powershell script adds "--" to arguments


NSCP.EXE file Version: (32Bit)

Hi, I’m trying a PowerShell script with arguments.

Unfortunately, the argument always “–” added.

How can I use arguments without this “–” is added.

The entry in the nsclient.ini .:

[/settings/external scripts/scripts]
check_updates=cmd /c echo scripts\check_windows_updates.ps1 -maxcrit $ARG1$; exit $LastExitCode | "%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe" -command -

My test command:

nscp.exe client -q check_updates -a 30

The Output:
Here are the argument “–30” its must be 30.

C:\Program Files (x86)\ICINGA2\NSClient++\scripts\check_windows_updates.ps1 : C
annot process argument transformation on parameter 'maxcrit'. Cannot convert va
lue "--30" to type "System.Int32". Error: "Input string was not in a correct fo
At line:1 char:43
+ scripts\check_windows_updates.ps1 -maxcrit <<<<  --30; exit $LastExitCode
    + CategoryInfo          : InvalidData: (:) [check_windows_updates.ps1], Pa
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,check_windo


Not sure if you’ve already solved this issue, but for whoever also stumble upon the similar error, the way to remove the “–” is to use the tag --raw-argument instead. So the new command would look like:

nscp.exe client -q check_updates --raw-argument 30

If ever in doubt of what options you can use, just run

nscp.exe client --help

To allow arguments for your script, you will need to update your nsclient.ini to add the following:

[/settings/external scripts] allow arguments=true