diff --git a/sudo.ps1 b/sudo.ps1 index 70e5ebb..2f9272c 100644 --- a/sudo.ps1 +++ b/sudo.ps1 @@ -1,10 +1,7 @@ if(!$args) { "usage: sudo "; exit 1 } function is_admin { - $id = [security.principal.windowsidentity]::getcurrent() - $name = $id.name -replace '^[^\\]*\\', '' - $admin_group = (gwmi win32_group -filter "LocalAccount=True AND SID='S-1-5-32-544'").name # be language-agnostic - $res = gwmi win32_groupuser | ? { $_.groupcomponent -match "name=`"$admin_group`"" -and $_.partcomponent -match "name=`"$name`"" } + $res = net localgroup administrators |? { $_ -match $env:username } if($res) { $true } }