-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMicrosoft Intune Company Portal Repair.sh
More file actions
122 lines (89 loc) · 4.76 KB
/
Microsoft Intune Company Portal Repair.sh
File metadata and controls
122 lines (89 loc) · 4.76 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
####################################################################################################
#
# ABOUT
#
# Microsoft Intune Company Portal Repair
# See: https://docs.microsoft.com/en-us/mem/intune/protect/troubleshoot-jamf#cause-6
# See: https://support.microsoft.com/en-us/help/4131870/
#
####################################################################################################
#
# HISTORY
#
# Version 0.0.1, 11-Jun-2020, Dan K. Snelson
# Original version
#
####################################################################################################
echo " "
echo "################################################"
echo "# Microsoft Intune Company Portal Repair 0.0.1 #"
echo "################################################"
echo " "
###
# Variables
###
loggedInUser=$( /bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }' )
###
# Functions
###
removeKeychainGenericPassword() {
echo " " # Blank line for readability
echo "• Keychain generic password to delete: ${1}"
echo "`/usr/bin/security delete-generic-password -l "${1}" /Users/${loggedInUser}/Library/Keychains/login.keychain-db`"
}
removeKeychainCertificate() {
echo " " # Blank line for readability
echo "• Keychain certificate to delete: ${1}"
echo "`/usr/bin/security delete-certificate -c "${1}" /Users/${loggedInUser}/Library/Keychains/login.keychain-db`"
}
removeKeychainIdentity() {
echo " " # Blank line for readability
echo "• Keychain identity to find: ${1}"
# hashID=$( /usr/bin/security find-identity -s "${1}" /Users/${loggedInUser}/Library/Keychains/login.keychain-db | /usr/bin/grep -A 1 "Matching identities" | /usr/bin/awk {'print $2'} | /usr/bin/tail -1 )
hashID=$( /usr/bin/security find-certificate -a -Z /Users/${loggedInUser}/Library/Keychains/login.keychain-db | /usr/bin/grep -B 9 "${1}" | /usr/bin/grep "SHA-1" | /usr/bin/awk '{print $3}' )
echo "• Keychain identity to delete: ${1}, a.k.a. ${hashID}"
echo "`/usr/bin/security delete-identity -Z ${hashID} /Users/${loggedInUser}/Library/Keychains/login.keychain-db`"
# /usr/bin/su \- "${loggedInUser}" -c "/usr/bin/security delete-identity -Z ${hashID} /Users/${loggedInUser}/Library/Keychains/login.keychain-db"
}
###
# Program
###
echo "• Quit Company Portal"
/usr/bin/pkill -l -U ${loggedInUser} "Company Portal"
/usr/bin/pkill -l -U ${loggedInUser} "nsurlstoraged"
echo "• Remove Company Portal.app"
/bin/rm -R "/Applications/Company Portal.app"
echo "• Perform JamfAAD clean"
echo "`/Library/Application\ Support/JAMF/Jamf.app/Contents/MacOS/JamfAAD.app/Contents/MacOS/JamfAAD -verbose clean`"
echo "• Remove ${loggedInUser} Company Portal Supporting Files"
/bin/rm -v "/Users/${loggedInUser}/Library/Application Support/com.microsoft.CompanyPortal.usercontext.info"
/bin/rm -Rv "/Users/${loggedInUser}/Library/Application Support/com.microsoft.CompanyPortal"
/bin/rm -Rv "/Users/${loggedInUser}/Library/WebKit/com.microsoft.CompanyPortal"
#/bin/rm -v "/Users/${loggedInUser}/Library/Application Support/com.jamfsoftware.selfservice.mac"
#/bin/rm -v "/Users/${loggedInUser}/Library/Application Support/com.jamfsoftware.selfservice.mac.savedState"
/bin/rm -v "/Users/${loggedInUser}/Library/WebKit/com.microsoft.CompanyPortal.savedState"
echo "• Remove Company Portal Supporting Files"
/bin/rm -v "/Library/Preferences/com.microsoft.CompanyPortal.plist"
/bin/rm -v "/Library/Application Support/com.microsoft.CompanyPortal.usercontext.info"
/bin/rm -v "/Library/Application Support/com.microsoft.CompanyPortal"
echo "• Remove Cookies"
/usr/bin/su \- "${loggedInUser}" -c "/bin/rm -fv /Users/${loggedInUser}/Library/Cookies/com.microsoft.CompanyPortal.binarycookies"
/usr/bin/su \- "${loggedInUser}" -c "/bin/rm -fv /Users/${loggedInUser}/Library/Cookies/com.jamf.management.jamfAAD.binarycookies"
echo "• Remove Keychain Generic Passwords"
removeKeychainGenericPassword "com.microsoft.CompanyPortal"
removeKeychainGenericPassword "com.microsoft.CompanyPortal.HockeySDK"
removeKeychainGenericPassword "enterpriseregistration.windows.net"
removeKeychainGenericPassword "https://device.login.microsoftonline.com"
removeKeychainGenericPassword "https://device.login.microsoftonline.com/"
echo "• Remove Keychain Identity"
removeKeychainIdentity "MS-ORGANIZATION-ACCESS"
# removeKeychainIdentity "Microsoft Session Transport Key" # NOT WORKING
# removeKeychainIdentity "Microsoft Workplace Join Key" # NOT WORKING
# echo "• Update computer inventory"
# /usr/local/bin/jamf recon
# echo "• Install Microsoft Intune Company Portal"
# /usr/local/bin/jamf policy -event CompanyPortalRepair -verbose
# echo "• Register with Intune"
# /Library/Application\ Support/JAMF/Jamf.app/Contents/MacOS/JamfAAD.app/Contents/MacOS/JamfAAD -verbose registerWithIntune
exit 0