升级到 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
使用 Vagrant 1.7.4。
有什么想法吗?
最佳答案
我在 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 而不会出现错误。这显然不是一个长期的解决方案,但却让事情再次运转起来。可能还有其他脚本也被破坏了,但我还没有遇到过它们。
关于使用 Hyper-V 的 Windows 10 上的 Vagrant 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31790077/