AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1624925
Accepted
Nils
Nils
Asked: 2021-02-11 03:59:28 +0800 CST2021-02-11 03:59:28 +0800 CST 2021-02-11 03:59:28 +0800 CST

在 Hyper-V 中使用 Vagrant 需要什么

  • 772

我已经按照文档中的描述设置了 vagrant 。

运行时,vagrant up我收到以下消息:

Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
The Hyper-V cmdlets for PowerShell are not available! Vagrant
requires these to control Hyper-V. Please enable them in the
"Windows Features" control panel and try again.

虽然我理解这个信息,但我觉得这不是根本问题。我做了

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

和以下重新启动。

Get-VM列出我所有的机器。所以我觉得应该安装 Hyper-V cmdlet 并且可以使用。

这是在 Windows 10 20H2 上运行的,Vagrant 版本是 2.2.14,Hyper-V PowerShell 模块版本是 2.0.0.0

我在这里想念什么?

编辑:

已安装的 Hyper-V 功能包括:

在此处输入图像描述

PowerShell 版本:

> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

我还交叉发布到了讨论.hashicorp.com

编辑 2

错误来自\Vagrant\embedded\gems\2.2.14\gems\vagrant-2.2.14\plugins\providers\hyperv\scripts\check_hyperv.ps1which 基本上确实Get-Command "Hyper-V\Get-VMSwitch",如果失败则报告错误。

Hyper-V\Get-VMSwitch现在,如果没有一些“帮助” ,我的系统似乎无法加载:

❯ get-command "Hyper-V\Get-VMSwitch"
get-command : The term 'Hyper-V\Get-VMSwitch' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ get-command "Hyper-V\Get-VMSwitch"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Hyper-V\Get-VMSwitch:String) [Get-Command], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand

❯ get-command "Get-VMSwitch"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-VMSwitch                                       2.0.0.0    Hyper-V


❯ get-command "Hyper-V\Get-VMSwitch"

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-VMSwitch                                       2.0.0.0    Hyper-V
**strong text**

vagrant hyper-v
  • 2 2 个回答
  • 285 Views

2 个回答

  • Voted
  1. Best Answer
    harrymc
    2021-02-18T01:07:21+08:002021-02-18T01:07:21+08:00

    据我所知,Vagrant 的安装是根据文档正确完成的。我看不出有什么不对,所有评论都被发帖人回答了。

    我的结论是,使用 Hyper-V 的 Vagrant 在最新的 Windows 10 升级下存在问题。

    我看到的选项是:

    • 等待 Vagrant 的更正版本
    • 向 HashiCorp 支持 (不太可能得到答案)或 Vagrant 社区解决问题
    • Vagrant 在使用 Hyper-V 之前首先使用了 VirtualBox,并且很可能仍在使用它。在等待 Hyper-V 解决方案(可能会更高效)时,您可能需要暂时回退到 VirtualBox。
    • 0
  2. Nils
    2021-02-18T05:10:46+08:002021-02-18T05:10:46+08:00

    为了在这里了解全貌,我将添加一个额外的答案:

    经过多次尝试和检查其他机器的交叉引用后,它归结为Import-Module Hyper-V无法在我的机器上工作,同时Get-VMSwitch会隐式加载 Hyper-V 模块。

    这最终把我带到了$env:PSModulePath,在我的两台(!)机器上看起来像这样: 在此处输入图像描述

    (注意System.String[]最后)在新安装的机器上它包含%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules(而不是System.String[]瓦砾)

    所以。将环境更改PSModulePath为如下所示: 在此处输入图像描述

    解决了整个问题。

    • 0

相关问题

  • Linux Mint 在 Hyper-V 上无法正常工作,如何解决?

  • 从已迁移到 Hyper V 的 VM 中删除 VirtualBox Guest Additions

  • 如何在 Windows 10 上的 Hyper-V 管理器应用程序上创建 NAT 交换机

  • 流浪触发器并不像看起来那么简单

  • Azure VM 中的 Hyper-V

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    v15 为什么通过电缆(同轴电缆)的千兆位/秒 Internet 连接不能像光纤一样提供对称速度? 2020-01-25 08:53:31 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve