You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add user to crc-users and hyperv admins group in a single powershell admin call
this is done to avoid getting two UAC prompts during crc setup command
by combining both in a single call to powershell admin session we are losing
inidividual error messages to determine which action failed but in this case
its an acceptable trade-off, since the two actions are doing similar thing of
adding current member to a group, so its easy to narrow down the issue
returnfmt.Errorf("Failed checking if user is part of hyperv admins group")
113
-
}
114
-
if!strings.Contains(stdOut, "True") {
115
-
returnfmt.Errorf("User is not a member of the Hyper-V administrators group")
116
-
}
117
-
118
-
returnnil
119
-
}
120
-
121
-
funcfixUserPartOfHyperVAdmins() error {
122
-
_, _, err:=powershell.ExecuteAsAdmin("adding current user to Hyper-V administrator group", fmt.Sprintf("Add-LocalGroupMember -SID 'S-1-5-32-578' -Member '%s'", username()))
_, _, err:=powershell.ExecuteAsAdmin("adding current user to crc-users group", fmt.Sprintf("Add-LocalGroupMember -Group 'crc-users' -Member '%s'", username()))
0 commit comments