I have a script that used to work that cleans up some common home folders on an auto-login account, but recently I have discovered that it no longer works. The script is very simple and I see no reason why it wouldn't work:
# Fetch the target user if desired, otherwise use the currently logged in user.
if [ "$4" != "" ]; then
TargetUser=$4
else
TargetUser=$3
fi
echo "Target user is $TargetUser."
# Delete common user spaces of the targetted user.
rm -Rf /Users/$TargetUser/Desktop/*
rm -Rf /Users/$TargetUser/Documents/*
rm -Rf /Users/$TargetUser/Downloads/*
rm -Rf /Users/$TargetUser/Applications/*
rm -Rf /Users/$TargetUser/.Trash/*
exit 0
The problems is the script doesn't actually do anything. The policy runs as scheduled, and reports no errors, but nothing is actually deleted from any of the designated spaces. The logs report back that the correct user was targeted, the policy runs at Checkin, so the computer is fully up and logged in, but nothing is deleted, as if the script does not have rights to the target user's folder. I've always understood that Jamf ran all scripts as root and thus should have access to delete any files in these locations.
Furthermore, if I run the policy by actually running "sudo jamf policy -event {event trigger} from the computer locally, it actually works just fine, it's only when it runs as a result of the policy that it fails. I'm very confused by this. My computers are running MacOS 10.15.7 on the client and Jamf Pro 10.35.
