From 3d8b3def1f3ea12bd760b21405477372da47a428 Mon Sep 17 00:00:00 2001 From: Luke Sampson Date: Tue, 25 Feb 2014 18:03:57 +1000 Subject: [PATCH] sudo: be language-agnostic again (see issue #5) --- sudo.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sudo.ps1 b/sudo.ps1 index 2f9272c..05088a0 100644 --- a/sudo.ps1 +++ b/sudo.ps1 @@ -1,8 +1,9 @@ if(!$args) { "usage: sudo "; exit 1 } function is_admin { - $res = net localgroup administrators |? { $_ -match $env:username } - if($res) { $true } + $admin_group = (gwmi win32_group -filter "LocalAccount=True AND SID='S-1-5-32-544'").name # be language-agnostic + $admins = (net localgroup $admin_group) -join "`n" | sls '(?s)-+\n(.*)' |% { $_.matches.groups[1].value } + return $admins -split "`n" -match "^$env:username`$" } function sudo_do($parent_pid, $dir, $cmd) {