Script to change user password on Mac
IT administrators might desire to allocate a new password to the user for various reasons, such as improving security on the device. In such scenarios, you can run the below script to modify the login password for a user account from the Mac Terminal. With Hexnode UEM, admins can remotely run scripts using the Execute Custom Script action.
Scripting Language – Bash
File extension – .sh
Change user password
sudo dscl . -passwd /Users/username currentpassword newpassword
The above script utilizes the directory service command-line utility or dscl tool to modify the /User directory data (specifically the password). The
passwd command is used to change the password for the user username from the currentpassword to a newpassword.
Note that the keychain password will also get updated to the new password following a device restart.