End of school year lab scripts to clean up iMacs running Yosemite


Does anyone have any end of year scripts they use in their labs they wouldn't mind sharing? Looking to clean the up, and keep them spritely! :)



We just re-image the machines.

Honored Contributor

Start with a simple question:
What are you looking to clean up? Everyone will have different needs and different situations to deal with.

For example, if it's a lab, sure maybe re-imaging them may be the way to go. But if no one has admin access and you're keeping the software up to date or can update them in the summer using Casper (or whatever tool you use for software deployment), do you really need to re-image? At best maybe you just need to get rid of the user account(s) on the machines and not have to deal with re-imaging. Or if it's all just one standard local account then just wipe it and re-create it.


We also re-image our school labs. There is a way to delete specific accounts (see below)9dd4ca67bb894801a1b1dada8098cf22
Imaging takes us less time in the long run, than trying to clean up the machines

Edit: "Student" is the name of a test account we use to ensure what we did, actually did what it was supposed to. This does not delete ALL student accounts.

Valued Contributor


do a search for a for loop that removes users, I recall one here in the past few years. If no one replies or you cannot locate it, ill post mine in the morning


Valued Contributor II

posted a link to an account cleanup thread over here today


Valued Contributor II

Like others, I still prefer wiping and reimaging lab machines over the summer. I know you're already running 10.10, but in our case most of our lab and cart machines will be moving to Yosemite so the cleanest process is just to start fresh. As well, it actually takes less time to do a NetBoot Casper Imaging thin imaging workflow than it does to do an in-place OS upgrade.

Contributor II
Contributor II

+1 for re-imaging. Less of a hassle in my opinion.

New Contributor

+1 for uninstalling indexed packages. But yes the atom bomb approach is so darn quick these days.

A Mac Pro with bonded ethernet ports spitting out a netboot image to a Mac with an SSD has a reimage time just short of 10 minutes.

Don't forget /usr/sbin/jamf deleteAccount -username $user -deleteHomeDirectory is your friend.

Honored Contributor

I'm going to play devil's advocate here. Folks are saying imaging it faster. And this is most likely true if taken literally. However, is time really a factor when you consider that you are not actually standing in front of the computer. In other words, if the computer is left imaging overnight and takes 10 minutes or software is deployed and takes 30 minutes, what difference does it make? You're not there either way.

Other things to consider as well:
-How much sneaker net is involved in your setup. Are you going around and pressing N to netboot each computer? That takes time and actual effort as opposed to deploying software/updates via Casper which can be done from your desk.

-How many computers can you actually image at a time? How many computers do you have? Let's say it's only 10 computers at a time with a total of 50 machines with each taking 10 minutes to image. Suddenly you've got 50 mins in just imaging. The more computers, the more time. You can see how this doesn't scale well.

-Is there anything that needs to be manually done after first boot that you haven't automated yet? That also time and walking around (or a lot of remoting into computers).

Anyways, those are just things to consider. Time is definitely a consideration to think about. But I think it's more worth while to automate, put in some extra hard work, and do things right from the beginning and not have to worry about needing to re-image every year. This scales a lot better.