我已经按照文档中的描述设置了 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.ps1
which 基本上确实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**