Powershell scriptnames as arguments


#1

Hi Michael,

1st of all: thanks for your wonderful work!

I have one question relaying on ps-handling (client is 0.5.0.62) Checks will be made by NRPE from Nagios host, on windows side we are using wrapped scripts for that, similar to that:

… [/settings/external scripts/wrapped scripts] check_script1=script1.ps1 $ARGS$ check_script2=script2.ps1 $ARGS$ check_script3=script3.ps1 $ARGS$ check_script4=script4.ps1 $ARGS$ … [/settings/external scripts/wrappings] ps1=cmd /c echo If (-Not (Test-Path “scripts%SCRIPT%”) ) { Write-Host “UNKNOWN: Script "%SCRIPT%" not found.”; exit(3) }; scripts%SCRIPT% $ARGS$; exit($lastexitcode) | powershell.exe /noprofile -command - …

everything is fine and working - no problems.

My question: is there a possibility to have ONE line under wrapped scripts, which is handling ALL scriptnames?

Something like: check_ps-scripts=variable_Scriptname_from_NRPE $ARGS$

So we will be able to have a oneliner which enables us to use every scriptname without the need to customize it in each case.

If you have further questions please let me know.

Best regards, Joachim


#2

You might be able to make a generic script and the argument used with that script tells the script to call the correct script.

The issue I see here however is if the system allows the particular PS scripts to run on their own. The other issue is what permissions or account does the called script run under.

I have never done this before with NSClient but it does work in scripting.