-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows: Using inline powershell in args with cmd.script
and shell: powershell
#56195
Comments
A possible workaround would be to use i.e. this works, but how to get
|
Looking through the history, I didn't see any conversation about the usage of |
@twangboy Can you verify this please? |
Verified |
Description of Issue
The way salt invokes powershell seems to make it impossible to pass inline powershell to
cmd.script
args, to allow for values being built-up in ps objects. I.e. how would you run a script that requires a SecureString or a PSCredential as a parameter?Setup
Say you have the script foo.ps1:
And you want to call it with cmd.script:
When you run this state, you get an error:
This is because when calling powershell.exe with
-File
, all the arguments are passed as strings. This means the inline powershell is not executed; it is simply treated exactly as a string.You can run the command in the cmd shell to repro easily:
Contrast this with just removing
-File
in the command, it works!:And if I make that change locally in my salt install, just removing
-File
:The text was updated successfully, but these errors were encountered: