Page 1 of 1

Issue passing parameters

Posted: Mon Jan 28, 2019 4:41 pm
by bmccarty
Having issues with using parameters in the Powershell pugin. I get the same results if I do a full function in the script panel as my quick little example. Can you let me know what I am doing wrong?

if I setup a param input and try to use the optional parameters, it is getting appended to the command line and breaking somewhere along the way. I've tested this against multiple client machines with the same results.

I made a quick example of what I am seeing. :|

Here is the output in the console window:

Sending script to agent .....
Script CMD = @powershell -NoProfile -ExecutionPolicy unrestricted -file "%windir%\temp\myPSScript.ps1 -identity administrator"
Executing Script ....Processing -File 'C:\Windows\temp\myPSScript.ps1 -identity administrator' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.

Re: Issue passing parameters

Posted: Tue Jan 29, 2019 3:18 pm
by Cubert
What version are you on?

Current version is 2.2.6


I believe we fixed that bug already. Looking at my current code base, that command is now generated as such.

Code: Select all

CMD = String.Format("@powershell -NoProfile -ExecutionPolicy unrestricted -file ""{0}"" {1}", myFile, OptPrams)

"MyFile" is now quoted but the optional prams are outside the quotes which should fix the error your seeing.

Let me know if this is on version or not.

Re: Issue passing parameters

Posted: Tue Jan 29, 2019 3:30 pm
by bmccarty
We are running 2.2.4, I'll check 2.2.6 and post an update if needed. Thank you.

Re: Issue passing parameters

Posted: Tue Jan 29, 2019 3:35 pm
by Cubert

Re: Issue passing parameters

Posted: Fri Feb 01, 2019 5:51 pm
by bmccarty
Works like a charm.
There should probably be some information for formatting the optional parameters field. I noticed if I pass an argument encapsulated in single quotes, that the text is getting sent double encapsulated in single quotes and thus fails. Not really a problem but a a best practice I generally encapsulate my input to the parameter

Note that there is a spelling error in the run page.

Re: Issue passing parameters

Posted: Mon Feb 04, 2019 3:18 pm
by Cubert
Awesome sauce!