From 30b5ace84eb71e1bfa50e5338691d0f4bdb22794 Mon Sep 17 00:00:00 2001 From: olivbour Date: Tue, 19 Nov 2019 17:05:11 +0100 Subject: [PATCH] Fix for #2989 For using an SID as parameter - which is better because of potential i18n issue with role name - "isInRole()" expect a "System.Security.Principal.SecurityIdentifier" object instead of a "String". That's because of this error that isHypervAdministrator() always return false and and consequently "Administrator" role is requested. --- drivers/hyperv/powershell.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hyperv/powershell.go b/drivers/hyperv/powershell.go index 5175791fd5..71e74b3c59 100644 --- a/drivers/hyperv/powershell.go +++ b/drivers/hyperv/powershell.go @@ -85,7 +85,7 @@ func isAdministrator() (bool, error) { } func isHypervAdministrator() bool { - stdout, err := cmdOut(`@([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole("S-1-5-32-578")`) + stdout, err := cmdOut(`@([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(([System.Security.Principal.SecurityIdentifier]::new("S-1-5-32-578")))`) if err != nil { log.Debug(err) return false