We have hundreds of computers with LDAP setup and when students login their profiles remain for life. IS there an easy script or something that could be run to clean out the entire /Users directory all but select users?
Provided you're merely dumping the user data, you could use a bash script. Something like:
#!/bin/bash for user in $( ls /Users ); do if [[ "$user" != "<someadmin>" || "$user" != "<someotheradmin>" ]]; then rm -rf "/Users/$user" fi done
For removing users from the local directory, you need to use
dscl. Check out this SuperUser answer for a launching pad on using dscl to remove an account from OS X's local directory.
If this is a lab you may just want to reset them back to a disk image periodically. This way any changes including any saved files will be lost, but it would return the machine back to a predetermined state.