Script to delete inactive accounts on computers

MarcosRocha
New Contributor

Hello everyone,

I need help to create a new script and employ on my work. Can you help me?

I need a script that removes a user account from all computers if the user has inactivity for maybe 30 days.
I search about this task and only find removing from AD and removing from Mobile, and I want to remove it from computers that have the user account on it.

I'm new in JAMF world, so I am grateful for any help.

Best Regards.

7 REPLIES 7

MarcosRocha
New Contributor

Any news?

cbrewer
Valued Contributor II

tlarkin
Honored Contributor

If you use FileVault 2 and do this, you're gonna have a bad time

cbrewer
Valued Contributor II

@tlarkin If you stick to using "sysadminctl -deleteUser" I think it won't let you delete the last secure token holder. I could be wrong though.

tlarkin
Honored Contributor

When you re-add the user, you are gonna have a bad time, gotta do expect stuff

TechSpecialist
Contributor

I'm after a similar script. I think what I want is this one: https://www.jamf.com/jamf-nation/discussions/15210/assistance-needed-deleting-mobile-accounts-older-than-30-days but for some reason it isn't working properly for me (see my reply to that post). I'm wondering if this is a Catalina thing? Or am I doing something wrong? I'm after a script that deletes local users (+home folders) after X days with the exception of custom set User accounts. The local accounts are not AD/Mobile Users but regular Local accounts.

Any help is much appreciated.

Mauricio
Contributor III

@MagicMick I've added some comments into that post.

One possible cause is SIP