macOS script (deleting users) in Jamf School resulting in error

EdwardB
New Contributor II

Hi,

 

I try to delete users from a Mac with a script in Jamf School. The script is correct and works perfectly fine in Jamf Pro.

In Jamf School it results in an error:

<main> delete status: eDSPermissionError
<dscl_cmd> DS Error: -14120 (eDSPermissionError) (1)

Has anyone an idea to solve this issue?

 

This is the script:

#!/bin/bash
 
users=$( dscl . ls /Users | grep -v '_' | grep -v 'root' | grep -v 'daemon' | grep -v 'nobody' | grep -v 'localadmin' | grep -v 'BEHEER' | grep -v 'Guest' )
 
echo "Removing user accounts."
for a in ${users}; do
    # delete user
    /usr/bin/dscl . delete /Users/"$a" || { echo "Could not remove user $a"; exit 1; }
 
    # delete home folder
    /bin/rm -rf /Users/"$a" || { echo "Could not remove home directory of $a"; exit 2; }
    echo "Executed for: $a"
done
 
echo "Users accounts removed!"
exit 0

 

0 REPLIES 0