Vagrant: Script: import_vm_vmcx.ps1

Created on 29 Dec 2017  ·  40Comments  ·  Source: hashicorp/vagrant

Versions

Expected behavior

just run vagrant up

Actual behavior

Bringing machine 'homestead-7' up with 'hyperv' provider...
==> homestead-7: Verifying Hyper-V is enabled...
==> homestead-7: Importing a Hyper-V instance
    homestead-7: Cloning virtual hard drive...
    homestead-7: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

字符串缺少终止符: '。
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

other

I just install it and run vagrant up.when I use virtualbox ,it works well.I think what happend to hyperv.
I have been admin,too.

finally

Thank you for solve my question

enhancement providehyperv

Most helpful comment

Versions

  • Host: Windows 10 Enterprise, Version 1703, OS Build 15063.909
  • Vagrant 2.0.2
  • laravel/homestead (hyperv, 5.1.0)
  • Hyper-V 10.0.15063.850
  • PowerShell 5.1.15063.909

Error

λ vagrant up
Bringing machine 'homestead-7' up with 'hyperv' provider...
==> homestead-7: Verifying Hyper-V is enabled...
==> homestead-7: Importing a Hyper-V instance
    homestead-7: Cloning virtual hard drive...
    homestead-7: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Hyper-V\Compare-VM : Failed to import a virtual machine.
At C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-2.0.2\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:33 char:14
+ $vmConfig = (Hyper-V\Compare-VM -Copy -GenerateNewID @VmProperties)
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-VM], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.CompareVM

All 40 comments

Can you share the Vagrantfile and some info on where you got this box or how you built it? That would be helpful

Please also provide:

  • Installed Vagrant version number.
  • Gist of debug output showing the error.

Thanks!

I also got this problem , i try version 2.0.1 and 1.9.8, but they both show the same error.

The box is laravel/homestead (hyperv, 5.0.1).
My system is win 10.

Bringing machine 'homestead-7' up with 'hyperv' provider...
==> homestead-7: Verifying Hyper-V is enabled...
==> homestead-7: Importing a Hyper-V instance
    homestead-7: Cloning virtual hard drive...
    homestead-7: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

字符串缺少终止符: '。
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRec
   ordException
    + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

Hi the same happen to me, i update my windows and activate the version 2.0 of powershell and works

I have similar issue.

OS: Win10
PowerShell: 5.1
Vagrant: 2.0.1
box: bento/ubuntu-14.04

    default: Cloning virtual hard drive...
    default: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Compare-VM : Не удалось импортировать виртуальную машину.
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-2.0.1\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:33 знак:14
+ $vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-VM], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.CompareVM

Debug log: https://gist.github.com/yethee/5e876158c3738d88cf61360df2942fd8

@yethee what's the local directory (pwd) when this happens? I think there may be a problem with how https://github.com/hashicorp/vagrant/blob/master/plugins/providers/hyperv/scripts/import_vm_vmcx.ps1 builds and escapes file paths on non-English systems.

On my system with all English characters in the path, it works. I'm using Vagrant 2.0.1 on Windows 10 build 16299.15

PS C:\VMs\bentotest> vagrant init bento/ubuntu-14.04
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
PS C:\VMs\bentotest> vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Box 'bento/ubuntu-14.04' could not be found. Attempting to find and install...
    default: Box Provider: hyperv
    default: Box Version: >= 0
==> default: Loading metadata for box 'bento/ubuntu-14.04'
    default: URL: https://vagrantcloud.com/bento/ubuntu-14.04
==> default: Adding box 'bento/ubuntu-14.04' (v201801.02.0) for provider: hyperv
    default: Downloading: https://vagrantcloud.com/bento/boxes/ubuntu-14.04/versions/201801.02.0/providers/hyperv.box
    default:
==> default: Successfully added box 'bento/ubuntu-14.04' (v201801.02.0) for 'hyperv'!
==> default: Importing a Hyper-V instance
    default: Please choose a switch to attach to your Hyper-V instance.
    default: If none of these are appropriate, please open the Hyper-V manager
    default: to create a new virtual switch.
    default:
    default: 1) LowerPort
    default: 2) Default Switch
    default: 3) External
    default:
    default: What switch would you like to use? 3
    default: Cloning virtual hard drive...
    default: Creating and registering the VM...
    default: Setting VM Integration Services
    default: Successfully imported a VM with name: ubuntu-14.04-amd64

@PatrickLang hi, in my case both paths, working and profile directory, contain only English characters.

D:\Projects\vagranttest> vagrant init bento/ubuntu-14.04
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
D:\Projects\vagranttest> vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Importing a Hyper-V instance
    default: Please choose a switch to attach to your Hyper-V instance.
    default: If none of these are appropriate, please open the Hyper-V manager
    default: to create a new virtual switch.
    default:
    default: 1) Shared
    default: 2) External
    default:
    default: What switch would you like to use? 2
    default: Cloning virtual hard drive...
    default: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Compare-VM : Не удалось импортировать виртуальную машину.
C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-2.0.1\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:33 знак:14
+ $vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-VM], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.CompareVM

Dump of $VmProperties:

Name                           Value
----                           -----
Path                           C:\Users\Deni\.vagrant.d\boxes\bento-VAGRANTSLASH-ubuntu-14.04\201801.02.0\hyperv\Virtual Machines\A8118DFC-06FF-4AD5-B7D2-3CC39BF63983.vmcx
SnapshotFilePath               D:\Projects\vagranttest\.vagrant\machines\default\hyperv\Snapshots
VhdDestinationPath             D:\Projects\vagranttest\.vagrant\machines\default\hyperv\Virtual Hard Disks
VirtualMachinePath             D:\Projects\vagranttest\.vagrant\machines\default\hyperv

OS Version: 10.0.14393.2035

Seems, the image from bento is not compatible with my version of Hyper-V.

I tried to use another box (generic/ubuntu1604) and it works.

Vagrant version

vagrant 2.0.2

Host operating system

Windows 10 Build 15063.850

Guest operating system

  • box: bento/ubuntu-14.04
  • box: bento/ubuntu-16.04
  • box: generic/ubuntu1604

Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "generic/ubuntu1604"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  config.vm.provider "virtualbox" do |v|
    v.memory = 4096
    v.cpus = 4
  end

  config.vm.provider "hyperv" do |hyperv|
    hyperv.memory = 4096
    hyperv.cpus = 4
  end 


  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
  config.vm.provision "shell", path: "provision.sh"
end

Debug output

Expected behavior

  • successful vagrant up

Actual behavior

unexpected powershell exception

Steps to reproduce

  1. vagrant up --provider=hyperv

This seems to be a box specific issue. I just tested and bento/ubuntu 1604 has this issue however generic/ubuntu 1604 does not. Should we just move to close this issue and report it to whoever maintains the bento boxes, as they might need to reevaluate their image creation process?

If anyone knows how the generic boxes are built (packer templates ideally) then I can figure out why bento boxes might not be working. It seems that the commonality across the different reports is older versions of Windows 10/2016 and Hyper-V so if folks can include full operating system strings/versions that would be ideal.

As a note: I only _very_ recently added Hyper-V boxes to bento and have only been built/tested with Windows 10 Pro 1709 10.0.16299. Happy to help troubleshoot but need to know what exactly is going wrong in the ps1 check on these systems to see if it's even a thing that can be fixed to account for older versions.

It seems the generic boxes are Hyper-V Gen1, the bento boxes are all Gen2 which might explain why older systems are having issues with them.

Marking this as an enhancement to see if we can do any kind of inspection to provide a usable error message.

I submitted debug logs showing evidence that both box types bento and generic fail during vagrant up. I was using Windows 10 Build 15063.850 and Vagrant 2.0.2. Is this considered an older system or a Hyper-V Gen1 system?

Since the offical docs do really mention such details, which upgrade paths would you suggest? My motivation is to evaluate whether I can use HyperV provider when running Vagrant on Windows 10 Pro machines prior to fallback to using VirtualBox. Is this a good place to talk about issues with Vagrant providers?

It seems like there are three factors at play in the issue:

  • non-English characters in paths
  • hyperv/windows version
  • import_vm_vmcx.ps1 error handling

Things I do know:

  • Gen1 or Gen2 boxes mentioned above work fine on Windows 10 Pro 10.0.16299+ (English/US)
  • boxes also have a "hardware version"[1] which can be relevant

Stats from my system that is used to build/test bento for reference:

λ  [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      16299  0

λ  Get-VMHostSupportedVersion -Default

Name                                                  Version IsDefault
----                                                  ------- ---------
Microsoft Windows 10 Fall Creators Update/Server 1709 8.2     True

Things I don't know:

  • how the generic boxes are made
  • the settings centos boxes are made with (they seem to use something super custom and is exported from another builder to gen1 hyperv, if anyone has any clue I'd love to hear more but it was a rabbit hole)
  • what happens when Win10 w/ differing character sets works.
  • if there is a nice table somewhere making this easier to figure out

I'm going to be throwing some safety code in kitchen-vagrant and a note for the bento repo around the versions of things we can assert work but hopefully this information is of use to Vagrant folk like @chrisroberts in their debugging.

any progress on this?
I don't have any non-english characters in paths and still get the error.

In order to make the narrowing down of things easier for the maintainers, could you provide the Windows version, the supported host version, Vagrant version, and box being used @KarlBaumann?

Not that it'll fix it but the nature of this kind of error condition lends itself to specific so the more collected ideally the more informed the fix.

Versions

  • Host: Windows 10 Enterprise, Version 1703, OS Build 15063.909
  • Vagrant 2.0.2
  • laravel/homestead (hyperv, 5.1.0)
  • Hyper-V 10.0.15063.850
  • PowerShell 5.1.15063.909

Error

λ vagrant up
Bringing machine 'homestead-7' up with 'hyperv' provider...
==> homestead-7: Verifying Hyper-V is enabled...
==> homestead-7: Importing a Hyper-V instance
    homestead-7: Cloning virtual hard drive...
    homestead-7: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Hyper-V\Compare-VM : Failed to import a virtual machine.
At C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-2.0.2\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:33 char:14
+ $vmConfig = (Hyper-V\Compare-VM -Copy -GenerateNewID @VmProperties)
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-VM], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.CompareVM

I can get laravel/homestead to come up and it looks to be Gen 2 - my specs/versions are above but this definitely is starting to look more like the boxes being newer gen/hardware version than the OS/Hyper-V supports.

I'd be curious if you can bring up generic/ubuntu1604 @KarlBaumann as that box appears to be Gen 1. Also if you could run Get-VMHostSupportedVersion -Default that would be great.

generic/ubuntu1604 almost worked:

C:\Users\baumanisk\Development\vagrant\boxes
λ vagrant init generic/ubuntu1604
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

C:\Users\baumanisk\Development\vagrant\boxes
λ vagrant up
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Box 'generic/ubuntu1604' could not be found. Attempting to find and install...
    default: Box Provider: hyperv
    default: Box Version: >= 0
==> default: Loading metadata for box 'generic/ubuntu1604'
    default: URL: https://vagrantcloud.com/generic/ubuntu1604
==> default: Adding box 'generic/ubuntu1604' (v1.3.30) for provider: hyperv
    default: Downloading: https://vagrantcloud.com/generic/boxes/ubuntu1604/versions/1.3.30/providers/hyperv.box
    default:
==> default: Successfully added box 'generic/ubuntu1604' (v1.3.30) for 'hyperv'!
==> default: Configured Dynamic memory allocation, maxmemory is 2048
==> default: Configured startup memory is 2048
==> default: Configured cpus number is 2
==> default: Importing a Hyper-V instance
    default: Cloning virtual hard drive...
    default: Creating and registering the VM...
    default: Setting VM Integration Services
    default: Successfully imported a VM with name: generic-ubuntu1604-hyperv
==> default: Starting the machine...
==> default: Waiting for the machine to report its IP address...
    default: Timeout: 120 seconds
Hyper-V failed to determine your machine's IP address within the
configured timeout. Please verify the machine properly booted and
the network works. To do this, open the Hyper-V manager, find your
virtual machine, and connect to it.

The most common cause for this error is that the running virtual
machine doesn't have the latest Hyper-V integration drivers. Please
research for your operating system how to install these in order
for the VM to properly communicate its IP address to Hyper-V.

Get-VMHostSupportedVersion -Default returns this:

PS C:\development\Homestead> Get-VMHostSupportedVersion -Default

Name                                                Version IsDefault
----                                                ------- ---------
Microsoft Windows 10 Anniversary Update/Server 2016 8.0     True

I want to update my failure report using Ubuntu boxes from bento and generic using Vagrant 2.0.2

I updated to Windows 10 Version 1709 (Build 16299.309)
Boxes from bento still fail

But these boxes work

I noticed that both centos/7 and generic boxes create a HyperV VM using config version 8.2. Bento boxes VMs used config version 8.0.

FYI
During trying generic boxes and writing this post I updated to Vagrant 2.0.3 and learned how to use the latest boxes by version pinning in Vagrantfile like shown below.

config.vm.box_version = "201801.02.0"

I hope this feedback helps debugging this issue.

@saschagottfried What failure did you encounter with the bento boxes? And do you know which version of the bento box you were encountering the error with?

@chrisroberts

Failure with bento/ubuntu-14.04 v201801.02.0

The issue was resolved by using box version v201803.24.0 released one day after my last comment. Now this box creates a HyperV VM using config version 8.2 as well - similar to the other boxes that already worked.

For context on the bento builds: I have nothing special setting the config version so I am guessing I'm just getting whatever the defaults are based on Windows 10 patch level and/or Packer.

My conclusion is that this issue still can happen: provided a rare combination of Windows 10, Vagrant and some Ubuntu boxes (HyperV provider).

Since my first comment in 02/2018 I have updated both host OS and the boxes and the issue was resolved. This sounds like: works on my machine

With respect to the bento hyperv boxes, which are provided on an experimental basis as noted in the readme, they are built on my personal home machine which is the only thing I have to validate them so yes, it's very much "works on machine".

@saschagottfried Thanks for letting me know that things "worked themselves out" on your machine.

@cheeseplus Thanks for the context and extra information on how the builds are done. Windows 10 and Hyper-V is very much a moving target that does make things a bit more challenging to debug.

I'm going to leave this issue open for now, mainly as a placeholder for "better error information". I'm planning to start overhauling the Hyper-V provider for the 2.1.1 release to get better parity with the other built-in providers and better UX (useful error messages being one of the top items on the list).

Cheers!

@chrisroberts I ended up just having to make my own VM images anyway, it's not that hard actually and if you have a decently powerful machine it should only take about an hour or so.

Did anybody figure out a solution to get the laravel/homestead box working? I'm getting similar errors to what was posted earlier in this thread. Here are the errors I'm getting along with my Vagrant and Windows versions:

PS C:\Users\tpeel\homestead> vagrant up
Bringing machine 'homestead-7' up with 'hyperv' provider...
==> homestead-7: Verifying Hyper-V is enabled...
==> homestead-7: Importing a Hyper-V instance
    homestead-7: Please choose a switch to attach to your Hyper-V instance.
    homestead-7: If none of these are appropriate, please open the Hyper-V manager
    homestead-7: to create a new virtual switch.
    homestead-7:
    homestead-7: 1) DockerNAT
    homestead-7: 2) Default Switch
    homestead-7:
    homestead-7: What switch would you like to use? 2
    homestead-7: Cloning virtual hard drive...
    homestead-7: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Hyper-V\Compare-VM : Failed to import a virtual machine.
At C:\HashiCorp\Vagrant\embedded\gems\2.1.1\gems\vagrant-2.1.1\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:33
char:14
+ $vmConfig = (Hyper-V\Compare-VM -Copy -GenerateNewID @VmProperties)
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-VM], VirtualizationException
    + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.CompareVM

PS C:\Users\tpeel\homestead> Hyper-V\Compare-VM

cmdlet Compare-VM at command pipeline position 1
Supply values for the following parameters:
Name:
PS C:\Users\tpeel\homestead> vagrant version
Installed Version: 2.1.1
Latest Version: 2.1.1

You're running an up-to-date version of Vagrant!
PS C:\Users\tpeel\homestead> Get-VMHostSupportedVersion -Default

Name                                                  Version IsDefault
----                                                  ------- ---------
Microsoft Windows 10 Fall Creators Update/Server 1709 8.2     True

I'm also getting this error. I'm on Windows Server 2016 64bit 1607, build 14393.2214. Vagrant version 2.11.

Vagrant.configure("2") do |config|
  config.vm.box = "generic/ubuntu1604"
  config.vm.hostname = "node3"
  config.vm.network "public_network", bridge: "Primary Virtual Switch"
  config.vm.boot_timeout = "600"
  config.vm.provider "hyperv" do |hv|
    hv.vmname = "Kubernetes Node"
    hv.cpus = "2"
    hv.memory = "2048"
    hv.auto_start_action = "Start"
    hv.auto_stop_action = "Save"
    hv.vm_integration_services = {
      guest_service_interface: true,
      heartbeat: true,
      key_value_pair_exchange: true,
      shutdown: true,
      time_synchronization: true,
      vss: true
    }
  end
end

I was experiencing the same issue as well trying to get the latest version of Laravel Homestead to work. It seems that perhaps the box was created using Windows 10 Version 1803 and that Windows version uses Hyper-V VM Version 8.3 which does not seem to work on Windows 1709.

As soon as I upgraded Windows to 1803 Hyper-V\Compare-VM command ran successfully.

Resolved via #9872

Cheers!

I have the same exact issue. All my Box image works in Windows 10, but the same setup does not work in Windows 2016.

C:\vagrant\2016>vagrant up
Bringing machine 'web4' up with 'hyperv' provider...
==> web4: Verifying Hyper-V is enabled...
==> web4: Verifying Hyper-V is accessible...
==> web4: Importing a Hyper-V instance
web4: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm.ps1
Error:

Failed to import a virtual machine.

It's happening here too, in Windows 2016.

Vagrant 2.2.0
PSVersion 5.1.14393.2515
Windows Microsoft Hyper-V Server 2016

I've tried with the following boxes along with my template:

  • bento/ubuntu-18.04
  • bento/ubuntu-16.04
  • generic/ubuntu1804
  • generic/ubuntu1604
> vagrant up
Bringing machine 'ubuntu' up with 'hyperv' provider...
==> ubuntu: Verifying Hyper-V is enabled...
==> ubuntu: Verifying Hyper-V is accessible...
==> ubuntu: Importing a Hyper-V instance
    ubuntu: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm.ps1
Error:

Failed to import a virtual machine.

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.define "ubuntu" do |ubuntu|
    ubuntu.vm.box = "generic/ubuntu1804"
    ubuntu.vm.hostname = "ubuntu-1804-x64"
    ubuntu.vm.network "public_network", bridge: "VSwitch"
    ubuntu.vm.synced_folder ".", "/vagrant", disabled: true
    ubuntu.vm.boot_timeout = 600

    ubuntu.vm.provider "hyperv" do |hv|
      hv.vmname = "ubuntu-1804-x64"
      hv.memory = 2048
      hv.cpus = 2
      hv.ip_address_timeout = 600
    end
  end
end

Please add information about Host OS and Hyper-V version with Powershell command.

Get-VMHostSupportedVersion -Default

Please add information about Host OS and Hyper-V version with Powershell command.

Get-VMHostSupportedVersion -Default

Here it is:

> Get-VMHostSupportedVersion -Default

Name                                                Version IsDefault
----                                                ------- ---------
Microsoft Windows 10 Anniversary Update/Server 2016 8.0     True

The most recent versions of the Vagrant boxes you mentioned, create Hyper-V VMs with configuration 8.2 (or even 8.3). When Host OS and/or Hyper-V was older, for example 8.0, the Vagrant provider task "Creating and registering VM" failed.

Do you have the opportunity to update Windows Server 2016 ?
If you can not update, try older versions of these Vagrant boxes.

Example given here - older Host OS and generic/ubuntu1604 version 1.3.30

The most recent versions of the Vagrant boxes you mentioned, create Hyper-V VMs with configuration 8.2 (or even 8.3). When Host OS and/or Hyper-V was older, for example 8.0, the Vagrant provider task "Creating and registering VM" failed.

Do you have the opportunity to update Windows Server 2016 ?
If you can not update, try older versions of these Vagrant boxes.

Example given here - older Host OS and generic/ubuntu1604 version 1.3.30

I'll update the system and see if it works.

Thanks for helping.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RobertSwirsky picture RobertSwirsky  ·  3Comments

cbednarski picture cbednarski  ·  3Comments

Cbeck527 picture Cbeck527  ·  3Comments

StefanScherer picture StefanScherer  ·  3Comments

tomhking picture tomhking  ·  3Comments