Skip to content

Instantly share code, notes, and snippets.

@lucascantor
Created January 27, 2018 07:50
Show Gist options
  • Save lucascantor/5390619ac45edae2904a9435c7cd78bc to your computer and use it in GitHub Desktop.
Save lucascantor/5390619ac45edae2904a9435c7cd78bc to your computer and use it in GitHub Desktop.
Demote all admin users to standard users, excluding a specified exempt local admin user
#!/bin/bash
localAccts=$(dscl . list /Users UniqueID | awk '$2>500{print $1}' | grep -v <exempt username>)
while read account; do
echo "Making sure $account is not an admin"
dseditgroup -o edit -d $account admin
done < <(echo "$localAccts")
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment