Hi,
I'm running a very basic script, which works, to change the local admin password on all our Macs. But, I want to know how to check if the currentPwd already matches the newPwd, and if so then it must exit.
How do I do that?
if [ currentPwd == newPwd ] then
echo 'password is correct'
else
#change account password
fi
Thank you to @adolfsson for the initial idea:
The Script below works but as you can see its not very 'clever'
Script:
currentPassword="$4"
newPassword="$5"
accountName="$6"
adminUser="remoteadmin"
#Check that we are changing ONLY for remoteadmin
if [ "$adminUser" == "${accountName}" ]
then
#Change management account locally on mac
sudo dscl . passwd /Users/"${accountName}" "${currentPassword}" "${newPassword}"
echo " Local Admin Account - Password changed! "
#Report management account password back to JSS
sudo jamf recon -sshUsername remoteadmin -sshPassword "${newPassword}"
echo " Local Management Account - password passed to JSS! "
else
echo " You are trying to change the wrong account. No Changes! "
fi