diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index b3d167a7684..14da1bc6dc1 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -1119,6 +1119,7 @@ jobs: RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1" SALT_TRANSPORT: ${{ matrix.transport }} TMPDIR: ${{ runner.temp }} + shell: powershell run: > nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- -k "win" --suppress-no-test-exit-code @@ -1145,6 +1146,7 @@ jobs: RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1" SALT_TRANSPORT: ${{ matrix.transport }} TMPDIR: ${{ runner.temp }} + shell: powershell run: > nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- -k "win" --suppress-no-test-exit-code --no-fast-tests --slow-tests @@ -1171,6 +1173,7 @@ jobs: RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1" SALT_TRANSPORT: ${{ matrix.transport }} TMPDIR: ${{ runner.temp }} + shell: powershell run: > nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- -k "win" --suppress-no-test-exit-code --no-fast-tests --core-tests @@ -1197,6 +1200,7 @@ jobs: RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1" SALT_TRANSPORT: ${{ matrix.transport }} TMPDIR: ${{ runner.temp }} + shell: powershell run: > nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- -k "win" --suppress-no-test-exit-code --no-fast-tests --flaky-jail @@ -1223,6 +1227,7 @@ jobs: RAISE_DEPRECATIONS_RUNTIME_ERRORS: "1" SALT_TRANSPORT: ${{ matrix.transport }} TMPDIR: ${{ runner.temp }} + shell: powershell run: > nox --force-color -e ${{ inputs.nox-session }} -- ${{ matrix.tests-chunk }} -- --slow-tests --core-tests -k "win" --test-group-count=${{ matrix.test-group-count || 1 }} --test-group=${{ matrix.test-group || 1 }} diff --git a/salt/modules/cmdmod.py b/salt/modules/cmdmod.py index d6fc69f4a18..fe1d4412d00 100644 --- a/salt/modules/cmdmod.py +++ b/salt/modules/cmdmod.py @@ -2942,35 +2942,6 @@ def _cleanup_tempfile(path): cmd_path = _cmd_quote(path, escape=False) else: cmd_path = path - # import pathlib - # if not env: - # env = {} - # if shell.lower() == "powershell": - # mod_paths = [ - # pathlib.Path( - # rf'{os.getenv("SystemRoot")}\System32\WindowsPowerShell\v1.0\Modules' - # ), - # pathlib.Path(rf'{os.getenv("ProgramFiles")}\WindowsPowerShell\Modules'), - # ] - # else: - # mod_paths = [ - # pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\Modules'), - # pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\6.0.0\Modules'), - # pathlib.Path(rf'{os.getenv("ProgramFiles")}\PowerShell\7\Modules'), - # ] - # ps_module_path = [ - # pathlib.Path(x) for x in os.getenv("PSModulePath", "").split(";") - # ] - # for mod_path in mod_paths: - # if mod_path.exists(): - # if mod_path not in ps_module_path: - # ps_module_path.append(mod_path) - # mod_paths = "" - # for mod_path in ps_module_path: - # if mod_path: - # mod_paths += f"{str(path)};" - # env.update({"PSModulePath": mod_paths}) - # env.update({"PSModulePath": ""}) else: cmd_path = _cmd_quote(path) diff --git a/tests/pytests/functional/modules/cmd/test_script.py b/tests/pytests/functional/modules/cmd/test_script.py index b7093badfde..dcdd632fa70 100644 --- a/tests/pytests/functional/modules/cmd/test_script.py +++ b/tests/pytests/functional/modules/cmd/test_script.py @@ -57,12 +57,7 @@ def test_windows_script_args_powershell(cmd, shell, issue_56195): ) script = "salt://issue-56195/test.ps1" - ps_path = {"PSModulePath": ""} - ret = cmd.script(source=script, args=args, shell=shell, saltenv="base", env=ps_path) - - import_result = cmd.run("Import-Module Microsoft.PowerShell.Security", shell=shell) - powershell_version = cmd.run("$PSVersionTable", shell=shell) - ps_module_path = cmd.run("$env:PSModulePath", shell=shell) + ret = cmd.script(source=script, args=args, shell=shell, saltenv="base") assert ret["stdout"] == password