带有Hyper-V的Windows 10上的Vagrant错误

Mik*_*rto 5 vagrant windows-10 vagrant-windows

升级到Windows 10后运行:

$ vagrant up
Run Code Online (Sandbox Code Playgroud)

我们收到以下错误消息

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: get_vm_status.ps1
Error:

C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\providers\hyperv\scripts\get_vm_status.ps1 : Unable to
find type [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException].
At line:1 char:1
+ &('C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\prov ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Hyper...FailedException:TypeName) [get_vm_status.ps1], Ru
   ntimeException
    + FullyQualifiedErrorId : TypeNotFound,get_vm_status.ps1
Run Code Online (Sandbox Code Playgroud)

随着Vagrant 1.7.4.

有任何想法吗?

小智 14

我在Windows 10 Enteprise(第一次使用Vagrant)上全新安装Vagrant 1.7.4时遇到了同样的问题.

在最新版本的PowerShell中,VirtualizationOperationFailedException类型已被VirtualizationException替换.

我更改了C:\ HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.4\plugins\providers\hyperv\scripts\get_vm_status.ps1的第15行:

} catch [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException] {
Run Code Online (Sandbox Code Playgroud)

} catch [Microsoft.HyperV.PowerShell.VirtualizationException] {
Run Code Online (Sandbox Code Playgroud)

现在我可以毫无错误地使用vagrant up和vagrant状态.这显然不是一个长期的解决方案,但让事情再次发挥作用.可能还有其他脚本也被破坏但我还没有进入它们.