Packer user_data / EC2Launch on Windows example seems to lose connection on 5986

Using the powershell script here:


Set administrator password

… etc …
Start-Service -Name WinRM

when I run Packer, I can RDP in at this stage:
==> amazon-ebs: Waiting for instance () to become ready…
amazon-ebs: Private IP:
==> amazon-ebs: Pausing after run of step ‘StepRunSourceInstance’. Press enter to continue.

(assuming I wait a few minutes for the user_data to be fully processed) when both 5985 and 5986 have listeners attached:

PS C:\Users\Administrator> winrm e winrm/config/listener
Address = *
Transport = HTTP
Port = 5985
Enabled = true
URLPrefix = wsman
ListeningOn = ,, ::1, fe80::a0d0:473:9ee:fb15%8

Address = *
Transport = HTTPS
Port = 5986
Hostname = packer
Enabled = true
URLPrefix = wsman
CertificateThumbprint = 020032801EFF37A88967D1BCC2ABD3260DFA69BE

but if I then press Enter, it seems to run user_data.ps1 a 2nd time. E.g. stepping though the Packer output we then get to this stage:
2021/02/15 11:41:10 [INFO] (telemetry) Starting provisioner powershell
==> amazon-ebs: Pausing before the next provisioner . Press enter to continue.
==> amazon-ebs: Provisioning with Powershell…
==> amazon-ebs: Provisioning with powershell script: user_data.ps1
2021/02/15 11:41:39 packer-provisioner-powershell plugin: Opening user_data.ps1 for reading

at which time we lose connection to the 5986 port.

Any suggestions what the problem might be?

I’m just using the stock example from