Category filter
Script to delete user account on Mac
When employees leave an organization, the corporate devices assigned to them are re-distributed to other workers in the firm. Hence, organizations may require to delete the data and user account from the devices. However, manually doing this task is a time-consuming process. Hexnode lets you deploy scripts to delete the user account from Mac devices.
Scripting language – Bash
File extension – .sh
Delete the user account
1 |
sudo dscl . delete /users/<username> |
The ‘sysadminctl’ has been introduced on macOS 10.13. It enables you to manage user accounts much more easily compared to the ‘dscl’ command.
1 |
sysadminctl -deleteUser <username> |
Even after the execution of the script, the user’s home folder will not be deleted. The user data will remain on the device and can be retrieved later if needed by an admin.
Delete directories and files of the user
1 |
sudo rm -rf /users/<username> |
The user account and all associated data will be erased from the device if both commands are executed successively.