diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 56a38c5a53..b83dd4de83 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,10 @@ in development Fixed ~~~~~ +* Fix issue of WinRM parameter passing fails for larger scripts.#5538 + + Contributed by @ashwini-orchestral + * Fix Type error for ``time_diff`` critera comparison. convert the timediff value as float to match ``timedelta.total_seconds()`` return. #5462 diff --git a/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py b/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py index 1ff9f2ce1d..1fb5f8ac2e 100644 --- a/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py +++ b/contrib/runners/winrm_runner/tests/unit/test_winrm_base.py @@ -909,7 +909,7 @@ def test__run_ps_script(self, mock_tmp_script, mock_run_ps): mock_tmp_script.assert_called_with( "[System.IO.Path]::GetTempPath()", "$PSVersionTable" ) - mock_run_ps.assert_called_with("& {C:\\tmpscript.ps1}") + mock_run_ps.assert_called_with("C:\\tmpscript.ps1") @mock.patch("winrm_runner.winrm_base.WinRmBaseRunner._run_ps") @mock.patch("winrm_runner.winrm_base.WinRmBaseRunner._tmp_script") @@ -923,7 +923,7 @@ def test__run_ps_script_with_params(self, mock_tmp_script, mock_run_ps): mock_tmp_script.assert_called_with( "[System.IO.Path]::GetTempPath()", "Get-ChildItem" ) - mock_run_ps.assert_called_with("& {C:\\tmpscript.ps1} -param1 value1 arg1") + mock_run_ps.assert_called_with("C:\\tmpscript.ps1 -param1 value1 arg1") @mock.patch("winrm_runner.winrm_base.WinRmBaseRunner._run_ps") def test__run_ps_or_raise(self, mock_run_ps): diff --git a/contrib/runners/winrm_runner/winrm_runner/winrm_base.py b/contrib/runners/winrm_runner/winrm_runner/winrm_base.py index 232c902b62..8d35703138 100644 --- a/contrib/runners/winrm_runner/winrm_runner/winrm_base.py +++ b/contrib/runners/winrm_runner/winrm_runner/winrm_base.py @@ -401,9 +401,9 @@ def _run_ps_script(self, script, params=None): # handle deletion of the temporary file on exit of the with block with self._tmp_script(tmp_dir, script) as tmp_script: # the following wraps the script (from the file) in a script block ( {} ) - # executes it, passing in the parameters built above + # executes it, passing in the parameters built above. # https://docs.microsoft.com/en-us/powershell/scripting/core-powershell/console/powershell.exe-command-line-help - ps = "& {%s}" % (tmp_script) + ps = tmp_script if params: ps += " " + params return self._run_ps(ps)