Get The Scoop On What's New
Want to know what Plugins4Automate is doing for ConnectWise Automate? Come check out our blog and find out about new products and updates that we are working on! https://www.plugins4labtech.com/blogs/blog

Issue passing parameters

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

Issue passing parameters

Post by bmccarty » Mon Jan 28, 2019 4:41 pm

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 2162 times

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

Re: Issue passing parameters

Post by Cubert » Tue Jan 29, 2019 3:18 pm

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

Re: Issue passing parameters

Post by bmccarty » Tue Jan 29, 2019 3:30 pm

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

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

Re: Issue passing parameters

Post by Cubert » Tue Jan 29, 2019 3:35 pm


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

Re: Issue passing parameters

Post by bmccarty » Fri Feb 01, 2019 5:51 pm

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 2082 times

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

Re: Issue passing parameters

Post by Cubert » Mon Feb 04, 2019 3:18 pm

Awesome sauce!

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests