Posted on 08-17-2023 02:21 PM
I am using a script to remove student profiles from devices. I was testing the script and all seems well. My admin accounts are staying on the device, while removing unnecessary profiles. However, when I logged in at the Jamf Connect window I received the whole "your azure password does not match our local password" message......
How can this be if I deleted my profile? Something, somewhere on the machine is holding onto my credentials after deletion. What's strange is the same script removed my co-worker's profile and he can log in. Jamf connect says "creating your account." But I can't log in without supplying the old password. Even when I do enter the old password, it says it's incorrect... Is it my script?
# Get a list of all user accounts
user_list=$(dscl . -list /Users | grep -v '^_')
# Specify the admin account(s) that you want to exclude
excluded_users=("admin1" "admin2" "root" "management account")
# Loop through the user list and delete user profiles except admin accounts
for user in $user_list; do
if [[ ! " ${excluded_users[@]} " =~ " ${user} " ]]; then
if [[ "$user" != "Shared" ]]; then # Exclude 'Shared' user
echo "Deleting user profile for: $user"
sudo sysadminctl -deleteUser "/Users/$user"
sudo rm -rf "/Users/$user"
fi
fi
done