From a997a27b579d9203e986cfb6d3735e4ad9ae8886 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 27 Apr 2018 14:13:34 -0700 Subject: [PATCH] Update Windows Hyper-V check Checks only if the Hyper-V hypervisor is enabled instead of all Hyper-V features. This will allow detection where Hyper-V is in use for things like ApplicationGuard. Uses both Get-WindowsOptionalFeature and Get-WindowsFeature to support check on server and non-server version. --- lib/vagrant/util/platform.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 5bc0a603b..072c84087 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -107,9 +107,12 @@ module Vagrant return @_windows_hyperv_enabled if defined?(@_windows_hyperv_enabled) @_windows_hyperv_enabled = -> { - ps_cmd = "$(Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online).State" - output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd) - return output == 'Enabled' + ["Get-WindowsOptionalFeature", "Get-WindowsFeature"].each do |cmd_name| + ps_cmd = "$(#{cmd_name} -FeatureName Microsoft-Hyper-V-Hypervisor).State" + output = Vagrant::Util::PowerShell.execute_cmd(ps_cmd) + return true if output == "Enabled" + end + return false }.call return @_windows_hyperv_enabled