Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Fix for #2989
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
olivbour committed Nov 19, 2019
1 parent b170508 commit 6eaf4fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hyperv/powershell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6eaf4fa

Please sign in to comment.