Currently I run the following script to destroy the managed mobile user accounts left behind on machines (such as in my LMC computer labs). It appears to work, but the script (when run via Remote) claims to fail. I have listed the log below the actual script.
Is there something I am missing, or perhaps a better way to write this script? Any help would be great!
Script:
dscl . -delete /Users/
dscl . list /Users | grep -v "_"
#!/bin/bash
UserList=/bin/ls /Users | /usr/bin/grep -v "Shared"
for u in $UserList ; do
if [[ `/usr/bin/dscl . read /Groups/admin GroupMembership | /usr/bin/grep $u -c` == 1 ]]
then /bin/echo "Admin account detected skipping..."
else /usr/bin/dscl . delete /Users/$u && /bin/rm -rf /Users/$u
fi
done
Log (example):
/usr/sbin/jamf is version 8.61 Executing Policy 2013-02-22 at 4:06 PM | amccutchan | 1 Computer... Mounting afp://10.5.10.33/CasperShare to /Volumes/CasperShare... Running script mobile_users_destroy.sh... Script exit code: 185 Script result: <dscl_cmd> DS Error: -14009 (eDSUnknownNodeName) delete: Invalid Path admin daemon harpese macports nobody rhackbarth root <dscl_cmd> DS Error: -14009 (eDSUnknownNodeName) delete: Invalid Path Admin account detected skipping... <dscl_cmd> DS Error: -14009 (eDSUnknownNodeName) delete: Invalid Path Admin account detected skipping... <dscl_cmd> DS Error: -14009 (eDSUnknownNodeName) delete: Invalid Path Unmounting file server...
