Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talkingmoose/e615d92f48a419a163eb54be4777bdd7 to your computer and use it in GitHub Desktop.
Save talkingmoose/e615d92f48a419a163eb54be4777bdd7 to your computer and use it in GitHub Desktop.
Example for removing specific account from System Preferences > Internet Accounts for the current user.
#!/bin/bash
# get name of currently logged in user
currentUser=$( /usr/bin/stat -f "%Su" /dev/console )
echo "Current user is $currentUser."
# get current user's home folder
homeFolder=$( /usr/bin/dscl . read "/Users/$currentUser" NFSHomeDirectory | /usr/bin/awk -F ": " '{ print $2 }' )
# remove account by description name from Accounts sqlite database
/usr/bin/sqlite3 "$homeFolder/Library/Accounts/Accounts4.sqlite" 'DELETE FROM ZACCOUNT WHERE ZACCOUNTDESCRIPTION = "Exchange"'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment