Windows: Using inline powershell in args with cmd.script
and shell: powershell
#56195
Labels
fixed-pls-verify
fix is linked, bug author to confirm fix
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: