0
votes

Is there a way to pass switch operators to the powershell prompt that is created to execute scripts. Essentially I have a state file which executes a powershell script:

function1:
  cmd.script:
    - source: salt://utils/scripts/function1.ps1
    - shell: "powershell"
    - env: "-ExecutionPolicy bypass"

But this doesn't work.

Because a dirty solution is to run the script via cmd: %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -NonInteractive -executionpolicy Bypass -File

Any way to set the executionpolicy flag in the state file itself?

Thanks!

1
It looks like the current development branch (see github.com/saltstack/salt/blob/develop/salt/modules/cmdmod.py) sets the -ExecutionPolicy bypass option when running powershell scripts, so you could try using that. - Lee
Thanks Lee! I will try updating to the 2014.1.0 today - balwa

1 Answers

1
votes

try using a file.managed to deploy the sls that holds the .exe and then use and cmd.run instead of cmd.script for the execution