When running vagrant up I get the following message:
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.
While I understand the message, I feel this is not the underlying issue. I did
Now, my system seems to be unable to load Hyper-V\Get-VMSwitch without some “help”:
❯ 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
After much trying and checking other machines for cross-referenct it boiled down to Import-Module Hyper-V not working on my machine, while at the same time Get-VMSwitch would load the Hyper-V module.
This brought me eventually to $env:PSModulePath, which on two (!) of my machines looked like this:
(notice the System.String[] at the end) while on newly installed machines it contained %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules (and not the System.String[] rubble)
So. Changing PSModulePath environment to look like this:
Thank you good sir! This was also a problem for me, was scratching my head for couple of days!
After replacing the System.String with %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules vagrant up for hyperv is working for mew. Whew!
I wish I could buy you a beer!! Thank you!