I am needing a script that can be added to our summer update configuration that will delete every user with the exception of admins. Anyone had any luck doing this? I have tried using Tom Larkin's script and it seems to remove the home directories from /Users how ever the accounts are still populated in SystemPreferences>Accounts. Any ideas?
https://discussions.apple.com/message/12165862#12165862
dscl . -delete /Users/
dscl . list /Users | grep -v "_"
#!/bin/bash
UserList=`/bin/ls /Users | /usr/bin/grep -v "Shared"`
for u in $UserList ; do
if [[ `/usr/bin/dscl . read /Groups/admin GroupMembership | /usr/bin/grep $u -c` == 1 ]]
then /bin/echo "Admin account detected skipping..."
else /usr/bin/dscl . delete /Users/$u && /bin/rm -rf /Users/$u
fi
done