-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Keychain Entry Deletion.sh
83 lines (60 loc) · 1.86 KB
/
Keychain Entry Deletion.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
####################################################################################################
#
# ABOUT
#
# Removes Keychain entries as specified in JSS script parameters
#
####################################################################################################
#
# HISTORY
#
# Version 1.0, 6-Jun-2018, Dan K. Snelson
# Original version
#
####################################################################################################
### Variables
loggedInUser=$( /usr/bin/stat -f %Su "/dev/console" )
entryName1="$4" # Keychain Entry Name (i.e., "com.microsoft.SkypeForBusiness.HockeySDK")
entryName2="$5" # Keychain Entry Name (i.e., "skype")
entryName3="$6" # Keychain Entry Name (i.e., "Skype for Business")
entryName4="$7" # Keychain Entry Name
entryName5="$8" # Keychain Entry Name
entryName6="$9" # Keychain Entry Name
### Functions
removeKeychainEntry() {
echo " " # Blank line for readability
echo "* Keychain entry to remove: ${1}"
/usr/bin/security delete-generic-password -l "${1}" /Users/${loggedInUser}/Library/Keychains/login.keychain-db
echo "* Removed ${1}."
}
### Command
echo " "
echo "### Removing Keychain Entries ###"
echo " "
# Keychain Entry Name 1 to remove
if [ ! -z "${entryName1}" ]; then
removeKeychainEntry "${entryName1}"
fi
# Keychain Entry Name 2 to remove
if [ ! -z "${entryName2}" ]; then
removeKeychainEntry "${entryName2}"
fi
# Keychain Entry Name 3 to remove
if [ ! -z "${entryName3}" ]; then
removeKeychainEntry "${entryName3}"
fi
# Keychain Entry Name 4 to remove
if [ ! -z "${entryName4}" ]; then
removeKeychainEntry "${entryName4}"
fi
# Keychain Entry Name 5 to remove
if [ ! -z "${entryName5}" ]; then
removeKeychainEntry "${entryName5}"
fi
# Keychain Entry Name 6 to remove
if [ ! -z "${entryName6}" ]; then
removeKeychainEntry "${entryName6}"
fi
exit 0 ## Success
exit 1 ## Failure