The jamf binary comes with a lot of cool little features that you can use to script things quickly, because JAMF has already built things to help you. We’ll look at two really quick. The first is the deleteAccount verb which, surprisingly, deletes accounts. With that verb, you’ll use the -username operator to define a given user that you’d like to remove. That username is defined as the short name (or what dscl shows) of a given user. For example, if I wanted to remove the user rorygilmore, I’d run the following command:
/usr/sbin/jamf deleteAccount -username rorygilmore
You can then provide a popup on the screen that you completed that action:
/usr/sbin/jamf displayMessage -message “rorygilmore has been deleted"
You can then add a new user, using the createAccount verb. To do so, run the jamf binary using the createAccount verb. This verb provides for a number of options, including a short name (-username), a full name (-realname), a password (-password), a home directory (-home) and a default shell (-shell). If you want the user to be an admin of the system you can also add an -admin option. Below, we’ll string it all together:
/usr/sbin/jamf createAccount -username lorelaigilmore -realname "Lorelai Gilmore" -password lukedanes -home /Users/lorelai -shell bash -admin
When I do this stuff I like to run a quick recon again:
/usr/sbin/jamf recon
If you have any questions, you can use the help verb to see what all this thing can do:
/usr/sbin/jamf help
And if you need more information on a given verb, run the help verb followed by the one you need more information on:
/usr/sbin/jamf help policy