Created
August 26, 2020 22:29
-
-
Save talkingmoose/5f5b1819ae2bcb4ccd2a047c9616e3a1 to your computer and use it in GitHub Desktop.
Report if any macOS user accounts with admin privileges exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# list all users with UIDs above 501 | |
usersList=$( /usr/bin/dscl . -list /Users uid | /usr/bin/awk '$2 >= 501 { print $1 }' ) | |
# test for admin | |
while IFS= read aUser | |
do | |
/usr/sbin/dseditgroup -o checkmember -u "$aUser" admin 1>/dev/null | |
if [[ $? = "0" ]] ; then | |
echo "<result>Yes</result>" | |
exit 0 | |
fi | |
done <<< "$usersList" | |
echo "<result>No</result>" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment