Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Delete Managed Mobile Accounts

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)

Posted on Jul 25, 2010 9:07 AM

Reply
2 replies

Sep 24, 2010 11:47 AM in response to notverypc

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

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

Delete Managed Mobile Accounts

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.