How to change a user password in macOS

Effective password management is essential for maintaining security and operational efficiency in corporate macOS environments. Using Applivery, IT teams can remotely update user passwords across all managed Mac devices, ensuring consistent configuration, improved compliance, and reduced manual workload.

Step 1 - Create your script #

Copy and paste the following script into the editor, then adjust the necessary parameters:

  • USERNAME (user): Enter the macOS account username whose password you want to update.
  • NEWPASSWORD (new_password): Set the new password for the specified user.
				
					#!/bin/bash

# Define the username and the new password
USERNAME="username"  # Replace 'username' with the actual username
NEWPASSWORD="new_password"  # Replace 'new_password' with the desired password

# Change the user's password using dscl
dscl . -passwd /Users/"$USERNAME" "$NEWPASSWORD"

# Check if the change was successful
if [ $? -eq 0 ]; then
    echo "The password for user $USERNAME has been successfully changed."
else
    echo "There was an error trying to change the password for user $USERNAME."
fi
				
			

Assign a descriptive name to the script and click on Create to save it.

Step 2 - Assign script to policy #

Next, go to any of your Policies (1) and select the Scripts (2) section from the left-hand menu. Click the + Add Script (3) button.

scripts-policy

Next, select the script by typing its name and choose the execution method, and add any required arguments.

Depending on the selected execution method, the script will run automatically in Loop or Once mode, or it can be manually triggered from the Actions section within the Applivery Agent when configured as On-demand.

on-demand-scripts

Regularly updating user passwords is a critical cybersecurity practice. Automating this task through Applivery ensures fast, secure, and consistent credential updates, reducing risks associated with outdated passwords and keeping all macOS devices aligned with corporate security standards.

Updated on novembro 28, 2025
Was this article helpful?

On this page