Created
November 16, 2020 19:45
-
-
Save homebysix/69163b06ef0e6e1c2d3608a7bbfc7ea5 to your computer and use it in GitHub Desktop.
GlobalProtectService keychain item removal.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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