Open gildas opened 9 years ago
It's a good point, I'll mark this as an enhancement - I'm hoping its something trivial.
This also seems to cause failures if you upgrade PowerShell to 5 from a prior version on the next WinRM command that gets executed (file or script).
@mefellows seems this could be something in the underlying WinRb/WinRM gem. https://github.com/WinRb/winrm-fs/issues/18
See mefellows/vagrant-dsc/issues/21. This looks to be the same issue.
Hey, I've been playing around with this the last few days (as well as with PowerShell exit codes).
Passing -NoProfile
to the powershell.exe works however this means that you have to quote the command passing to PowerShell. This means you can't pass {{ .Vars }}
as the quotes that are passed in will not be escaped properly.
I'm happy to sacrifice having the environment variables to get cleaner output so my command looks like this.
"execute_command": "powershell.exe -NoProfile \"if (Test-Path variable:global:ProgressPreference){`$ProgressPreference='SilentlyContinue'}; & '{{.Path}}';exit `$LastExitCode\"; exit $LastExitCode",
I have kept the JSON so that the escape characters are a bit more obvious.
When running a powershell script in elevated mode, the output received by Packer contains the Progress object (System.Management.Automation.PSCustomObject) as an XML blob.
Example of a script that install .Net 3.5 via the
Install-WindowsFeature
Cmdlet (that produces a typical progress indicator in your Powershell session usually). Here is the output as shown when running packer:I cut the XML as it is quite huge.
IMO, that XML should not be visible (at least) or process properly by showing some progress text + % value (that'd be the best).