Hyper-V usable by members of Hyper-V admins group

pull/7790/head
Michał Regulski 2020-04-20 02:51:51 +02:00
parent a8c9e7a3cb
commit db6ed7c7d4
1 changed files with 2 additions and 2 deletions

View File

@ -89,9 +89,9 @@ func status() registry.State {
ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)
defer cancel() defer cancel()
cmd := exec.CommandContext(ctx, path, "Get-WindowsOptionalFeature", "-FeatureName", "Microsoft-Hyper-V-All", "-Online") cmd := exec.CommandContext(ctx, path, "@(Get-Wmiobject Win32_ComputerSystem).HypervisorPresent")
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if string(out) != "True\r\n" {
errorMessage := fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out) errorMessage := fmt.Errorf("%s failed:\n%s", strings.Join(cmd.Args, " "), out)
fixMessage := "Start PowerShell as Administrator, and run: 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All'" fixMessage := "Start PowerShell as Administrator, and run: 'Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All'"