I tried my best to find a solution with numerous script questions on stack overflow and internet, but I can not find the solution I need.
What I want to do is create a more automatic and less clickable solution to delete all mobile cached user accounts on the system. I log in and manually go to user accounts and delete users one at a time by clicking the โ-โ button and then โDelete immediatelyโ for user data. It works, but it is time consuming and I have better things to do with my time. So I knew there had to be a way to do this with a script.
I came across this code:
for cuser in `dscl . -list /Users AuthenticationAuthority | grep LocalCachedUser | awk '{print $1}' | tr '/n' ' '`; do
dscl . -delete /Users/$cuser
done
If I run this in the terminal, I get permission errors. So I decided that I need to run it using sudo. So I started learning how to create AppleScripts to run a script, but I cannot find the right way to do this.
Any ideas? By the way, I am new to writing scripts on Mac, so please comment on your code so that I know what is happening, and therefore I do not just run the script code, I donโt know what it will do. :)
thanks
source
share