Delete students home directory when the student not logged in

New Contributor III

What is the best Jamf way to delete students' home directory as a local account on a computer using BigSur when the student is not logged in? If anyone has a tip, I'm very grateful.


Valued Contributor

Seen a few ways, they are all getting harder to do.
I never fully delete the accounts. I have a script that runs and it clears out the majority of the contents, but leaves the users Library intact, apart from the cache files. Had too many issues with Adobe sign in's and other App settings that were causing issues with a total removal of the account. Currently Root can delete the Users Home folder, but that might change (I haven't tested this in Big Sur). If you know the Username, then dscl can remove the account.
If you want to automate this then setting it up as a local script on the Mac is pretty easy, and you need to launch it using a LaunchDaemon. This will run the script locally on the Mac as root. You will need to pull the local console logged in user account, so you don't remove the logged in user account. LaunchDaemons run at startup, but you can then schedule it to run at times.
I would also caution you to not remove your local admin accounts, as you will need their secure token to remain. It might be that the Secure Token will also stop you from deleting the account. Again, I haven't tested any of this.


Have you had luck with this? I had a script that worked great in Mojave but does not seem to delete the accounts in BigSur.