Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 6eaf4fa

Browse files
committed
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. Signed-off-by: Olivier Bourgeat <[email protected]>
1 parent b170508 commit 6eaf4fa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hyperv/powershell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func isAdministrator() (bool, error) {
8585
}
8686

8787
func isHypervAdministrator() bool {
88-
stdout, err := cmdOut(`@([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole("S-1-5-32-578")`)
88+
stdout, err := cmdOut(`@([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(([System.Security.Principal.SecurityIdentifier]::new("S-1-5-32-578")))`)
8989
if err != nil {
9090
log.Debug(err)
9191
return false

0 commit comments

Comments
 (0)