Vagrant: Destroying VM and associated drives after first reboot

Hello everyone

I’m having issues with a Windows 10 Evaluation Box on Virtual Box. I’ve built the box with packer with only minimal required settings. The box is getting syspreped just before the shutdown and compression of the box, until then everything runs smoothly. I also build Windows Server 2022/2019 boxes with the same settings and won’t get the error while uping them.

Find here the error message error.txt (48.5 KB). The error appears after the first reboot, means if I provision with a script instead of setting the hostname, it will fail after applying and rebooting. I’ve confirmed that the winrm services are running after the reboot. Does anyone experience a similar behavior?

Thanks in advance.

A Windows 11 Box with the same configuration won’t produce this error. Find here my winrm config:

$enableArgs=@{Force=$true}
try {
 $command=Get-Command Enable-PSRemoting
  if($command.Parameters.Keys -contains "skipnetworkprofilecheck"){
      $enableArgs.skipnetworkprofilecheck=$true
  }
}
catch {
  $global:error.RemoveAt(0)
}
get-netadapter | set-netconnectionprofile -NetworkCategory Private
Enable-PSRemoting @enableArgs
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/client/auth '@{Basic="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 4096

netsh advfirewall firewall add rule name="WinRM-HTTP" dir=in localport=5985 protocol=TCP action=allow
netsh advfirewall firewall add rule name="WinRM-HTTPS" dir=in localport=5986 protocol=TCP action=allow

Restart-Service winrm