Issue passing parameters

Post Reply
bmccarty
Posts: 3
Joined: Tue Jan 22, 2019 9:58 pm
5

Issue passing parameters

Post 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.
Attachments
2019-01-22_12-53-10, LTClient.png
2019-01-22_12-53-10, LTClient.png (8.47 KiB) Viewed 18838 times

User avatar
Cubert
Posts: 2552
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: Issue passing parameters

Post 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.

bmccarty
Posts: 3
Joined: Tue Jan 22, 2019 9:58 pm
5

Re: Issue passing parameters

Post by bmccarty »

We are running 2.2.4, I'll check 2.2.6 and post an update if needed. Thank you.

User avatar
Cubert
Posts: 2552
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: Issue passing parameters

Post by Cubert »


bmccarty
Posts: 3
Joined: Tue Jan 22, 2019 9:58 pm
5

Re: Issue passing parameters

Post 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.
Attachments
2019-02-01_09-45-07, LTClient.png
2019-02-01_09-45-07, LTClient.png (1.04 KiB) Viewed 18758 times

User avatar
Cubert
Posts: 2552
Joined: Tue Dec 29, 2015 7:57 pm
8
Contact:

Re: Issue passing parameters

Post by Cubert »

Awesome sauce!

Post Reply

Return to “PowerShell plugin for Labtech”