diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index b160f1bd9..b213add0e 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -141,10 +141,9 @@ module Vagrant @_windows_hyperv_enabled = -> { {:"Get-WindowsOptionalFeature" => ["-Online"], :"Get-WindowsFeature" => []}.each do |cmd_name, arguments| parameters = arguments.join " " + ps_cmd = "$(#{cmd_name} -FeatureName Microsoft-Hyper-V-Hypervisor #{parameters}).State" if cmd_name == "Get-WindowsFeature" ps_cmd = "if (Get-Command #{cmd_name} -ErrorAction SilentlyContinue){ $(#{cmd_name} -FeatureName Microsoft-Hyper-V-Hypervisor #{parameters}).State } else { 'Disabled' }" - else - ps_cmd = "$(#{cmd_name} -FeatureName Microsoft-Hyper-V-Hypervisor #{parameters}).State" end begin output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd)