How to remove a specific account in 10.14?

danreedphoto
New Contributor III

I'm having issues deleting a setup user account in 10.14+. After imaging completes, I have a script running the following:

!/bin/sh

/usr/local/bin/jamf deleteAccount -username admin -deleteHomeDirectory

exit 0

but it doesn't work. I'm looking for a simple script that I can run that will delete the user on logout. Does anyone have success with this and how did you do it, please?

3 REPLIES 3

mm2270
Legendary Contributor III

Is the account the only one on the Mac? Or at least the only 501+ ID account? Under 10.14 with regard to the SecureToken status, if that account is the only one with a SecureToken granted, then that might be why it's unable to delete it. The OS may be preventing it to avoid putting the Mac into an odd situation where no local account has a SecureToken.

If that doesn't sound like the issue, then it might be that the deleteAccount verb is using some command(s) under the hood that have to be updated. Normally, excepting the above situation that I mentioned, you can delete an account with sysadminctl Like so:

sudo sysadminctl -deleteUser <username>

You can give that a try, but if that doesn't work, it may be related the first situation I mentioned.

danreedphoto
New Contributor III

Okay. That worked AFTER I logged into the other user and passed on the security token. So, thank you for solving half of my equation. Is there a script that will pass the secure token to a mobile account on a mass basis?

jschlimmer
New Contributor III

sysadminctl is the only tool that can pass a securetoken. but you'll have to include a password in the script flags for both accounts.