hashicorp / hashicorp/packer

The -NonInteractive Parameter should be added by default when starting a powershell shell

Open
#12,637 3 comments 2 reactions 0 assignees View on GitHub
enhancement help wanted provisioner/powershell
Dominant language
Go
Stars
15.8k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

When a script called by the Powershell provisioner includes a command that involves a y/n prompt (or other kinds of interaction (e.g., Read-Host) the Powershell script will appear to hang as that script will wait indefinitely for the input. The [-NonInteractive Parameter](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1#-noninteractive) should be added by default when using the Powershell provisioner. This would result in an error instead of the apparent hanging when using commands requiring interactivity.

This can currently be worked around by specifying a custom [execute_command](https://developer.hashicorp.com/packer/docs/provisioners/powershell#execute_command), but it would be preferable to set the parameter by default.

_Originally posted by @floh96 in https://github.com/hashicorp/packer/issues/4916#issuecomment-1239297541_

Contributor guide

Open the contributing guide

Research direction

Start at the PowerShell provisioner entry point where its execute_command is assembled, and inspect any existing provisioner tests. Verify how the default command is built, then confirm that PowerShell starts with -NonInteractive by default and that commands requiring input fail instead of hanging.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.