Check for account create if missing update password if exisiting

Andy_McCaskill
Contributor

Hi everyone,

I am not the greatest at creating scripts. I was wondering if any of you could assist with a small management script I want to create.

I need a script to look for a local account on a computer. If the account is missing, it will create it. If the account is there, reset the password to a given entry.

Thank you all in advance for any assistance on creating this script!

1 REPLY 1

dan-snelson
Valued Contributor II

We use something along these lines to create the admin account (and we use a JSS Policy Local Accounts payload to reset it).

/bin/mkdir -p /private/var/${adminAccount}
/usr/sbin/sysadminctl -addUser ${adminAccount} -fullName ${adminAccount} -UID ${adminUID} -password "${adminPassword}" -home "/private/var/${adminAccount}" -admin
/usr/sbin/chown ${adminAccount} /private/var/${adminAccount}