Fixes the issue of Vagrant is unable to execute Get-WindowsOptionalFeature Command changes 2
Fixes #11932
This commit is contained in:
parent
b0a4109845
commit
88c5e17c5c
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user