winrm-ps-script ignores parameters when script is bigger
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.5k
- Forks
- 787
- PR merge metrics
- No merged PRs in 30d
Description
SUMMARY
winrm-ps-script ignores parameters when script is bigger
STACKSTORM VERSION
st2 3.2dev (dce1063), on Python 2.7.6
OS, environment, install method
st2-docker with tag:dev
Steps to reproduce the problem
Creat a winrm-ps-script Action with Parameters and the Script Content is large
Script Execute but without Parameters
# printer_set_printer_permissions.yaml
---
name: printer_set_printer_permissions
description: Set a Printer Permission on a Windows Server
pack: global
enabled: true
runner_type: winrm-ps-script
entry_point: printer_set_printer_permissions.ps1
parameters:
printername:
type: string
required: true
groupname:
type: string
required: true
action:
type: string
required: true
# printer_set_printer_permissions.ps1
[CmdletBinding()]
Param(
[string]$printername,
[string]$groupname,
[string]$action
)
return "Hello $printername $groupname $action"
# a Realy long Script i use some Code and comment it out for me it was like 210 Lines
#-------------------------------------------
# function Fail-Json($obj, $message){
# $result_object = New-Object PSCustomObject @{
# error_object = $obj
# error_message = $message
Expected Results
Script Execute with passed Parameters
Output Returns
Hello printernamevalue,..
Actual Results
Output Returns
Hello
Debugging
A small script getting run with "powershell -encodedcommand <script_encoded_as_base64> but a big script getting executed with follow command who is wrong i think
. & {<PathToFileOnHostAfterCopy>} -Parameter1 ParameterValue1 - Parameter2 ParameterValue2
What i know is in Powershell {} = Expand the Script and so the Parameters don't getting passed looks like
i changed follow line in winrm_base.py so the script gets executed correclty and parameters getting passed
# Line 376
ps = "& {%s}" % (tmp_script)
# Changed to
ps = "& %s" % (tmp_script)
because tmp_script = Path to Script and not the Script Content!
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 contrib/runners/winrm_runner/winrm_runner/winrm_base.py around line 376, where the issue identifies the command used for large scripts. Reproduce the behavior with a large PowerShell script and parameters, comparing it with the small-script execution path. Done means parameters are passed and the script returns the expected values for both script sizes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, python
- Domain
- devops, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100