Jump to content
Bmac

Powershell Manager for Labtech - issue with passing parameters

Recommended Posts

My issue seems to be passing optional parameters through to scripts.

Within my script I have something like the following

param (
[string]$identity
)

... do stuff

When I specify the -identity cbell in the optional parameters I am getting back the following error.

Executing Script ..Processing -File 'C:\Windows\temp\myPSScript.ps1 -identity cbell' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.

I have tried with and without double/single quotes.

 

Any ideas what I am doing wrong?

 

Share this post


Link to post
Share on other sites

What script function are you using? Can you post a screenshot? What server version/patch? It looks like it is trying to use the entire command line as the filename. But without details on how you are calling the script I couldn’t guess what you are doing wrong. (Or maybe you found a fresh bug!)

Share this post


Link to post
Share on other sites

Here is a quick example with some screenshots.

I've tried this with different patterns within the scripts and the parameter line, meaning placing single and double quotes in different locations to see if it was anything with the parsing of the text.  No change in the error.

I'm told we are on version 0.2.2.4  - I have no idea of the current versioning of the product.  I'm just the resident scripting guy.

The error I get in the Terminal Window is:

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.

For the screenshots in one I commented out the parameter assignment and specified the variable value, in the other I am passing the parameter argument just as I would from a normal console.

 

 

 

 

 

2019-01-22_12-53-10, LTClient.png

2019-01-22_12-54-13, LTClient.png

Share this post


Link to post
Share on other sites

I’m not familiar with that plugin, but it’s definitely doing something wrong. (Or the behavior of Automate changed and impacted the plugin)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×