2 Replies Latest reply: Sep 24, 2010 11:47 AM by Jacob P
Storm AI Level 1 Level 1 (0 points)
Good morning-

We have several labs on our campus that utilize AD integration for authentication. I'm running into a situation where I want to purge all of the managed,mobile accounts and I can't seem to find a way to do this. I thought that perhaps purging the /Users folder was my answer but that gets rid of my Administrator/Local Accounts and the Shared folder. Even doing that, if I run a "dscl . -list /Users UniqueID" the accounts still exist afterwards.

Does anyone have a script that I use in ARD that will do this? I have searched all of over and haven't found a solution yet.

MBP C2D 17", Mac OS X (10.6.3)
  • notverypc Level 1 Level 1 (35 points)
    Did you find a solution to this?? As this is what I'm trying to do as well.
  • Jacob P Level 1 Level 1 (0 points)
    Run the below script in ARD and it will delete all local users that are not admin accounts. I have tested this in 10.4.11, 10.5.8, and 10.6.4

    This script was written by Thomas Larkin.


    -----------------------------------

    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

    ----------------------------------------------------------------