Posted on 06-05-2024 03:24 PM
Trying to delete User accounts with JAMF Schools Script.
I had it not error before and it seemed to delete but the account would still be on the login screen. ~
#!/bin/bash
users=("Class1")
# Delete users and their home directories
for user in "${users[@]}"; do
# Check if the user exists
if dscl . -read /Users/$user &>/dev/null; then
# Delete the user account
sudo dscl . -delete /Users/$user
# Remove the user's home directory
sudo rm -rf /Users/$user
echo "Deleted User -> $user and their home directory"
else
echo "User $user does not exist"
fi
done
Im returning
1:233: execution error: /Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f.command: line 2: : command not found /Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f.command: line 4: : command not found /Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f.command: line 6: syntax error near unexpected token `do ' /Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f/com.zuludesk.scripting.08af6178-237d-11ef-8da8-024f99ac106f.command: line 6: `for user in "${users[@]}"; do ' (2