StackStorm/st2
View on GitHubPowerShell Script Runner not passing parameters to script
Open
#4,730 opened on Jun 28, 2019
buggood first issue
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