Things I have tried:
- LaunchAgent
- The LaunchAgent doesn't have permissions to run the commands in the script. Wasn't sure how to get around this.
- Policy on Login
- We use Wifi to authenticate and when the machine attempts to check for login policies, there isn't an active connection at that time and fails.
- Policy on Login (available offline)
- Simply not working. Nothing in logs either
#!/bin/sh
MobileUsers=`dscl . list /Users UniqueID | awk '$2 > 1000 {print $1}'`
LocalUsers=`dscl . list /Users UniqueID | awk '$2 > 500 && $2 < 1000 {print $1}'`
CurrentUser=$(ls -l /dev/console | cut -d " " -f4)
if [[ "$CurrentUser" == "localadmin" ]]; then
:
else
for User in $MobileUsers ;
do
if [[ "$User" == "$CurrentUser" ]]; then
echo "No mobile users found."
else
sudo dscl . delete /Users/"$User"
sudo rm -r /Users/"$User"
echo "$(date "+%Y.%m.%d %H:%M:%S") Removing $User"
fi
done
fi
This machine is a loaner. The idea is, we hand it to a user and they can log in and use the computer as much as they want. When the next user gets the machine and they log in, it will remove the account / information of the previous user.
Any help would be great.

