From 88c5e17c5ce301451712dca5195ce7a32ac0ead5 Mon Sep 17 00:00:00 2001 From: lyderX05 <69924216+lyderX05@users.noreply.github.com> Date: Thu, 1 Oct 2020 16:14:48 +0530 Subject: [PATCH] Fixes the issue of Vagrant is unable to execute Get-WindowsOptionalFeature Command changes 2 Fixes #11932 --- lib/vagrant/util/platform.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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)