Anyone have a good script for delete a admin account that is above UID 500? We want to give the users the ability to enroll from the enrollment page with their initially created account, but after they enroll we want to kill all expect the one account we put in. Since were dealing with accounts here wanted to see if anyone had any good script for it.
Something quick and dirty I came up with to get you started:
#!/bin/bash #get list of admins admins=$(dscl . -read /Groups/admin GroupMembership | sed 's/GroupMembership: //') #for each username in admins, check it's UniqueID, if it's known to be greater than 500, remove it. for user in $admins; do userID=$(dscl . -read /Users/$user UniqueID 2> /dev/null | sed 's/UniqueID: //') if [[ ! -z "$userID" ]]; then if [[ $userID -gt 500 ]];then #delete the user account via dscl echo "deleting user $user because it's an admin with a Unique ID:$userID greater than 500" else # keep the user echo "keeping user $user because it's Unique ID: $userID is less than 500" fi fi done