Need to change local admin account name and password or only password via script

Bhaskar
New Contributor

Hi, 

Thank you in advance,

 

Need script to change local admin name and password or only password in Mac system from Jamf.

 

I have created policy to change admin password. also I tried with the script. but its not work for me. 

 

 

 

5 REPLIES 5

AJPinto
Honored Contributor III

Does the account have a secure token?

No ..

Phantom5
Contributor II

Best way to deal with username changing would be using dscl, along with the command sysadminctl to deal with a user password and secureToken, the latter needing a local admin password to work.

There are several references to the local username in the user's local OD record that you need to care about, then use sysadminctl to update the users password and the secureToken. Also you need to rename the user's home folder name to reflect the new username.

Ok. But I manage to change the password with script and policy, but with new policy I am able rename local admin account but not the home directory name, Full name and login name.

 

Also with the same password I able to login into system with both user name and home directory showing only one user "Admin"  (below screen shot)

Screenshot 2023-11-28 at 12.13.41 PM.png

AJPinto
Honored Contributor III

You have to rename the user directory, before you can change the Username. You also cannot be logged in to macOS with the account that you are changing the Username for. If you are needing to change the Username, I would suggest just deleting the account and making a new one as you can completely break the account changing details like this.

 

I have not tested the terminal command, but I'd wager it would look something like this to change the Username. You will also need to rename the home directory.

dscl . change /Users/user RecordName user user2

 

Change the name of your macOS user account and home folder - Apple Support