You are here

how to call a powershell script with parameters

2 posts / 0 new
Last post
wwestra
wwestra's picture
how to call a powershell script with parameters

I have a custom powershell defined in NSC.INI

; custom checks

get-active-vdi-sessions=cmd /c type "C:\Program Files\Opsview Agent\scripts\custom\get-active-vdi-sessions.ps1"; | powershell.exe -command -

 

It returns performance data and exit codes just fine to Opsview.

But how do pass command line parameters from opsview to the powershell script ?

The service check uses check_nrpe with the following   -H $HOSTADDRESS$ -c get-active-vdi-sessions

Does anybody have a working example,

the stuff I find on Internet do not work.

 

Thanks.

 

 

 

 

dkatz
dkatz's picture
Re: how to call a powershell script with parameters

i have a powershell script that i run as: 

Counters.ps1 -counter Counter1_Local

the NSC.ini file has:

check_Counter=cmd /c echo scripts\Counters.ps1 $ARG1$ ; exit($lastexitcode) | powershell.exe -command -

and the service shows:

check_nrpe -H $HOSTADDRESS$ -c check_Counter -a '-counterName Counter1_local'

Hope this let you understand better :)