5

升级到 Windows 10 后运行:

$ vagrant up

我们收到以下错误消息

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

使用流浪者 1.7.4。

有任何想法吗?

4

4 回答 4

14

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

在最新版本的 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] {

} catch [Microsoft.HyperV.PowerShell.VirtualizationException] {

现在我可以毫无错误地使用 vagrant up 和 vagrant status 了。这显然不是一个长期的解决方案,但让事情再次发挥作用。可能还有其他脚本也损坏了,但我还没有遇到它们。

于 2015-08-07T19:55:05.647 回答
1

销毁然后重新创建虚拟机后,我遇到了同样的错误。

我删除了.vagrant/machines/hyperv文件夹,一切正常。

于 2016-04-11T13:04:27.900 回答
0

如果@jeff-r 的解决方案对您不起作用,您可以尝试更改:

} catch [Microsoft.HyperV.PowerShell.VirtualizationOperationFailedException] {

到:

} catch [Exception] {

小心,它也可能导致一些副作用。

于 2015-10-17T22:46:50.253 回答
0

在 win 10 上,您必须禁用“Hyper-V”才能运行 vagrant/virtualbox

于 2018-12-24T12:57:55.157 回答