powershell script with directory path as argument

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

powershell script with directory path as argument

Post by ruffsense »

Hi,

I have created my own powershell check file exsist script. But Im stuck when i use arguments. If i use a path as an argument. lik: D:\Temp\Center\ it won’t work. If i add the path to my script and the other arguments it works.

Is it not possible to add paths as an argument.

The line in the nsclient.ini is:

check_file_crm = cmd /c echo scripts\check_file.ps1 $ARG1$ $ARG2$ $ARG3$; exit ($lastexitcode) | powershell.exe -command –

To test the file i do it from my nagios server../check_nrpe -n -H 10.X.X.X -C check_file_crm -a D:\Temp\Center\ test.txt 60
I don't insult, I diagnose.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: powershell script with directory path as argument

Post by Box293 »

I'm pretty sure you need to use double backslahes in the path:

Code: Select all

./check_nrpe -n -H 10.X.X.X -C check_file_crm -a D:\\Temp\\Center\\ test.txt 60
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked