Pre-Ventura, I've been used a couple of different scripts to delete users' folders via a Jamf policy. It's worth noting this script only deleted the folder, but did not delete the user account with the OS. When a user with a deleted folder would log in again, their user folder would be recreated as a default user folder and they'd go on their merry way.
With Ventura, the script will delete the user folder, but when the user tries to log in again, the computer will hang. Testing has shown the problem is the lingering user account. If I manually delete the account, log in works normally for then.
I'm curious what scripts y'all are using to accomplish user removal in Ventura? I've been using the script below which removes the user accounts via "sysadminctl -deleteUser [username]", but sometimes it doesn't catch all the users.
#!/bin/bash
# Loop through users with homes in /Users; use grep to exclude any accounts you don't want removed (i.e. local admin and current user if policy runs while someone is logged in)
#Catch any users who had their profiles saved when their account was deleted
rm -rf "/Users/Deleted Users"
#shared is /Users/Shared, calmin is local admin account
for username in `ls /Users | grep -v Shared | grep -v calmin`
do
if [[ $username == `ls -l /dev/console | awk '{print $3}'` ]]; then
echo "Skipping user: $username (current user)"
else
echo "Removing user: $username"
sysadminctl -deleteUser $username
sleep .5
# Removes the user directory if for whatever reason sysadminctl doesn't catch it, or it's some rando folder without a user attached
rm -rf /Users/$username
echo "Removed user home folder: $username"
# enable fdesetup line if you FileVault active
# fdesetup remove -usertoremove $username
fi
done