Hey, I’m working on a script to clean up some of our employees’ mobile accounts from our AD-bound machines. The machines are set to create mobile accounts at login with no confirmation, and all our employee usernames have a “.” in them (like Mathew.Cooper). Here’s what I’ve got so far:
1 2 3 4 5 6 7 8 9 10 |
# list all users with the "." character in their names USERS=$( dscl . ls /Users | grep -e "\." ) # echo users echo Deleting the following users: $USERS # delete users /usr/bin/dscl . delete /Users/"$USERS" echo User accounts deleted # delete home folders /bin/rm -rf /Users/"$USERS" echo User home folders deleted |
It works for removing the accounts, but after rebooting, I can’t seem to add them back from the login screen. This could be a big problem if the employees can’t use their computers. Any ideas on what’s going wrong? Or maybe there’s a smarter way to handle this?