Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save homebysix/69163b06ef0e6e1c2d3608a7bbfc7ea5 to your computer and use it in GitHub Desktop.
Save homebysix/69163b06ef0e6e1c2d3608a7bbfc7ea5 to your computer and use it in GitHub Desktop.
GlobalProtectService keychain item removal.sh
#!/bin/bash
# Remove GlobalProtectService keychain item from all users' login keychains.
USER_LIST=$(/usr/bin/dscl . -list /Users UniqueID | awk '$2 > 500 {print $1}')
for THIS_USER in $USER_LIST; do
USER_HOME=$(/usr/bin/dscl . -read "/Users/$THIS_USER" NFSHomeDirectory | awk '{print $2}')
USER_KEYCHAIN="$USER_HOME/Library/Keychains/login.keychain-db"
if [[ -f "$USER_KEYCHAIN" ]]; then
if /usr/bin/security find-generic-password -s "GlobalProtectService" "$USER_KEYCHAIN" &>/dev/null; then
/usr/bin/security delete-generic-password -s "GlobalProtectService" "$USER_KEYCHAIN" &>/dev/null
echo "Deleted GlobalProtectService item from $THIS_USER login keychain."
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment