I could have sworn that i had already posted this but it looks like i didn’t. I posted the group policy we use to clean up users on our lab/library PCs, but we are actually mostly Mac os x. So I wrote a short bash script that can be sent out to the OS X computers through apple remote desktop.
I will give you the same warning i give my techs before they run this. You are deleting everything saved by any user not explicitly listed with a Username) echo “–saved i$” ;; section. Be 100% sure that no one has saved anything to their desktop or anywhere else in their local profile before running.
I make no claims that the code is pretty, just that it works.
#!/bin/bash clear echo "Cleaning up users ..."; cd /Users for i in *; do [ -d $i ] &&; case "$i" in admin) echo "-- Saved $i"; ;; Administrator) echo "-- Saved $i"; ;; Shared) echo "-- Saved $i"; ;; techstaff) echo "-- Saved $i"; ;; *) rm -rf $i echo "-- Deleted $i"; ;; esac done echo "...done";
You’ll need to create a case statement for each of the local accounts that you want to keep.
You can run it a few ways:
- The quickest would be to copy the script into the unix shell script portion of Apple Remote Desktop and send it to a handful of computers.
- You can also copy the script to a file and copy it out to all of the computers and then run it. If the file was called cleanuser.sh and you copied it to /tmp/, you would run these lines through the unix script part of ARD.
chmod +x /tmp/cleanuser.sh /tmp/cleanuser.sh
- Least desirable would be to copy the script to a file and then manually run it on each individual computer. Same two lines from above in terminal will run the script.