PowerShell Script Runner not passing parameters to script
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
SUMMARY
When a script is larger than the WINRM_MAX_CMD_LENGTH = 8192 the arguments are not being passed.
ISSUE TYPE
- Bug Report
STACKSTORM VERSION
st2 3.0.1, on Python 2.7.5
OS / ENVIRONMENT / INSTALL METHOD
CENTOS7 per stackstorm install guide
STEPS TO REPRODUCE
winrm_windump.yaml
---
name: "winrm_windump"
description: "Action that runs arg dump"
enabled: true
entry_point: "windows/dump.ps1"
runner_type: "winrm-ps-script"
parameters:
one:
type: string
default: "SOMEVALUE"
required: true
position: 0
description: the first arguments
dump.ps1
param($one="notset")
write-host "one: $one"
### Enough content of script comments and code to get past the 8192 byte boundary
### ...
### ...
EXPECTED RESULTS
one: SOMEVALUE
ACTUAL RESULTS
one: notset
I could not get positional or named parameters to successfully make it to the PS script. The issue appears to be in the _run_ps_script function in winrm_base.py:
ps = "& {%s}" % (tmp_script) ###the ampersand and braces should be removed here
if params:
ps += " " + params
return self._run_ps(ps)
Wrapping the braces around the script path is unnecessary and causes the arguments to be lost.
Quick workaround:
ps = "%s" % (tmp_script)
or simply:
ps = tmp_script
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in winrm_base.py at _run_ps_script and reproduce the issue with a PowerShell script larger than 8192 bytes and a parameter such as one. Verify that the runner passes positional or named arguments through to the script and that the output changes from the default value to the supplied value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, python
- Domain
- devops, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100