使用 Hyper-V 的 Windows 10 上的 Vagrant 错误

标签 vagrant windows-10 vagrant-windows

升级到 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/

相关文章:

powershell - 您的 token 尚未被授予执行此查询所需的范围。 'id' 字段需要以下范围之一 : ['read:packages' ],

c# - 在通用 Windows 平台中更改按钮样式

vagrant - 如何在Windows虚拟机上运行GUI应用程序?

php - Vagrant 虚拟主机/共享文件夹无法访问

node.js - 在 Ubuntu Trusty 64 上安装 nodejs 0.10.36

postgresql - 如何从 vagrant virtualbox 机器连接主机 PostgreSQL

vagrant - Kubernetes Guestbook Vagrant 前端服务EXTERNAL_IP问题

c++ - Windows 10 中的注册表权限

Vagrant - 无法使用 Puphpet 和 SMB 挂载在 Linux Guest 中挂载文件夹

ssh - 使用 MySQL Workbench 连接到 Vagrant Box