Category filter
Script to Change User Password on Mac
Sometimes, users might forget their password or administrators might desire to allocate a new password to the user. In such scenarios, you can use the below script to modify the login password for a user with a single line command from the Mac Terminal.
Device admins can remotely run scripts on Macs managed with Hexnode using the Execute Custom Script action.
Scripting Language – Bash
File extension – .sh
Change user password
1 |
sudo dscl . -passwd /Users/New\ user oldpassword 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 ‘New User’ from the oldpassword
to a newpassword
.