I used to have a pretty basic script that would revoke admin privileges to the logged in user but I noticed that it is no longer working. Here is what I've been using:
if [[ `/usr/bin/dscl . read /Groups/admin GroupMembership | /usr/bin/grep -c $3` == 0 ]]
then /bin/echo "$3 is NOT the admin group, exiting"
exit 0
else /bin/echo "$3 is an admin, demoting.."
fi
/usr/sbin/dseditgroup -o edit -d $3 -t user admin
Here is what I am seeing in the logs since last week:
Executing Policy RevokeAdminRights
Running script RevokeAdminPriviledges...
Script exit code: 64
Script result: usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
is an admin, demoting..
Group not found.
Error running script: return code was 64.
Can anybody help me with this?
