chef / chef/chef

ZD : powershell_script resource not honoring parameters while using Job-Start for background process

Open
#10,752 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Platform: Windows Type: Bug
Dominant language
Ruby
Stars
8.2k
Forks
2.5k
Avg merge
4d 5h
Merged PRs (30d)
23

Description

Description

As customer is describing the issue :

I am using a simple code below to run a powershell script that takes 2 parameters as a background job.
powershell_script 'test_install' do
code "Start-Job -ScriptBlock {#{script_dir}\test.ps1 $args} -ArgumentList 'one', 'two'"
end

The above code runs without any errors but is not passing the parameters to the script. However If I run the same code via powershell console as a command it works fine. Is there a bug around this. I can see there was a fix around the above behaviour which was done in powershell in October 2019: MicrosoftDocs/PowerShell-Docs#4944

Chef Version

Chef Infra Client v16.4.38

Platform Version

Replication Case

powershell_script 'test_install' do
code "Start-Job -ScriptBlock {#{script_dir}\test.ps1 $args} -ArgumentList 'one', 'two'"
end

The above code runs without any errors but is not passing the parameters to the script. However If I run the same code via powershell console as a command it works fine. Is there a bug around this. I can see there was a fix around the above behaviour which was done in powershell in October 2019: MicrosoftDocs/PowerShell-Docs#4944

Expected behavior

Parameters should get passed to the script.

Actual behavior

Doesn't pass parameters to script

Additional context

Running code "Start-Job -ScriptBlock { c:\test\.chef\local-mode-cache\cache\was_scripts\WASFixPacksInstall_Win.ps1 'install', 'CRQ123456' }" also not passing the parameters.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the powershell_script resource and reproduce the shown Start-Job example using the supplied Chef Infra Client version. Compare its behavior with the equivalent PowerShell console command; done means the script receives both parameters when run as a background job.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.