Add Office Reset scripts and README

This commit is contained in:
√(noham)²
2026-03-03 22:46:48 +01:00
commit e66ec57985
19 changed files with 2502 additions and 0 deletions

View File

@@ -0,0 +1,211 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_AutoUpdate"
autoload is-at-least
APP_NAME="Microsoft AutoUpdate"
DOWNLOAD_URL="https://go.microsoft.com/fwlink/?linkid=830196"
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
RepairApp() {
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $DOWNLOAD_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Stopping update services"
/usr/bin/pkill -9 'Microsoft AutoUpdate'
/usr/bin/pkill -9 'Microsoft Update Assistant'
/usr/bin/pkill -9 'Microsoft AU Daemon'
/usr/bin/pkill -9 'Microsoft AU Bootstrapper'
/usr/bin/pkill -9 'com.microsoft.autoupdate.helper'
/usr/bin/pkill -9 'com.microsoft.autoupdate.helpertool'
/usr/bin/pkill -9 'com.microsoft.autoupdate.bootstrapper.helper'
/bin/launchctl stop /Library/LaunchAgents/com.microsoft.update.agent.plist
/bin/launchctl stop /Library/LaunchAgents/com.microsoft.autoupdate.helper.plist
/bin/launchctl stop /Library/LaunchDaemons/com.microsoft.autoupdate.helper
/bin/launchctl stop /Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist
/bin/launchctl unload /Library/LaunchAgents/com.microsoft.update.agent.plist
/bin/launchctl unload /Library/LaunchAgents/com.microsoft.autoupdate.helper.plist
/bin/launchctl unload /Library/LaunchDaemons/com.microsoft.autoupdate.helper
/bin/launchctl unload /Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -f $HOME/Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.autoupdate.fba.plist
/bin/rm -f /Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f /Library/Preferences/com.microsoft.autoupdate.fba.plist
/bin/rm -f /var/root/Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f /var/root/Library/Preferences/com.microsoft.autoupdate.fba.plist
/bin/rm -rf $HOME/Library/Caches/com.microsoft.autoupdate2
/bin/rm -rf $HOME/Library/Caches/com.microsoft.autoupdate.fba
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.autoupdate2
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.autoupdate.fba
/bin/rm -rf $HOME/Library/Application\ Support/Microsoft\ AU\ Daemon
/bin/rm -rf /Library/Application\ Support/Microsoft/MERP2.0
/bin/rm -rf $TMPDIR/MSauClones
/bin/rm -rf /Library/Caches/com.microsoft.autoupdate.helper/
/bin/rm -rf /Library/Caches/com.microsoft.autoupdate.fba/
/bin/rm -f $TMPDIR/TelemetryUploadFilecom.microsoft.autoupdate.fba.txt
/bin/rm -f $TMPDIR/TelemetryUploadFilecom.microsoft.autoupdate2.txt
/bin/rm -rf /Applications/.Microsoft\ Word.app.installBackup
/bin/rm -rf /Applications/.Microsoft\ Excel.app.installBackup
/bin/rm -rf /Applications/.Microsoft\ PowerPoint.app.installBackup
/bin/rm -rf /Applications/.Microsoft\ Outlook.app.installBackup
/bin/rm -rf /Applications/.Microsoft\ OneNote.app.installBackup
/bin/rm -rf /Library/Logs/Microsoft/autoupdate.log
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 AcknowledgedDataCollectionPolicy -string 'RequiredDataOnly'
if [ -d "/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app" ]; then
echo "Office-Reset: Installing the latest version of ${APP_NAME}"
RepairApp
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Creating new preferences"
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app" "{ 'Application ID' = 'MSau04'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
WORD_VERSION=$(defaults read /Applications/Microsoft\ Word.app/Contents/Info.plist CFBundleVersion)
if [[ "${WORD_VERSION}" != "" ]]; then
if is-at-least 16.17 $WORD_VERSION; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Word.app" "{ 'Application ID' = 'MSWD2019'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
else
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Word.app" "{ 'Application ID' = 'MSWD15'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
fi
fi
EXCEL_VERSION=$(defaults read /Applications/Microsoft\ Excel.app/Contents/Info.plist CFBundleVersion)
if [[ "${EXCEL_VERSION}" != "" ]]; then
if is-at-least 16.17 $EXCEL_VERSION; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Excel.app" "{ 'Application ID' = 'XCEL2019'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
else
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Excel.app" "{ 'Application ID' = 'XCEL15'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
fi
fi
POWERPOINT_VERSION=$(defaults read /Applications/Microsoft\ PowerPoint.app/Contents/Info.plist CFBundleVersion)
if [[ "${POWERPOINT_VERSION}" != "" ]]; then
if is-at-least 16.17 $POWERPOINT_VERSION; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft PowerPoint.app" "{ 'Application ID' = 'PPT32019'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
else
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft PowerPoint.app" "{ 'Application ID' = 'PPT315'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
fi
fi
OUTLOOK_VERSION=$(defaults read /Applications/Microsoft\ Outlook.app/Contents/Info.plist CFBundleVersion)
if [[ "${OUTLOOK_VERSION}" != "" ]]; then
if is-at-least 16.17 $OUTLOOK_VERSION; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Outlook.app" "{ 'Application ID' = 'OPIM2019'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
else
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Outlook.app" "{ 'Application ID' = 'OPIM15'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
fi
fi
ONENOTE_VERSION=$(defaults read /Applications/Microsoft\ OneNote.app/Contents/Info.plist CFBundleVersion)
if [[ "${ONENOTE_VERSION}" != "" ]]; then
if is-at-least 16.17 $ONENOTE_VERSION; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft OneNote.app" "{ 'Application ID' = 'ONMC2019'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
else
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft OneNote.app" "{ 'Application ID' = 'ONMC15'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
fi
fi
if [ -d "/Applications/OneDrive.app" ]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/OneDrive.app" "{ 'Application ID' = 'ONDR18'; LCID = 1033 ; 'App Domain' = 'com.microsoft.office' ; }"
fi
if [ -d "/Applications/Microsoft Teams classic.app" ]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Teams classic.app" "{ 'Application ID' = 'TEAMS10'; LCID = 1033 ; }"
fi
if [ -d "/Applications/Microsoft Remote Desktop.app" ]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Microsoft Remote Desktop.app" "{ 'Application ID' = 'MSRD10'; LCID = 1033 ; }"
fi
if [ -d "/Applications/Skype For Business.app" ]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Skype For Business.app" "{ 'Application ID' = 'MSFB16'; LCID = 1033 ; }"
fi
if [ -d "/Applications/Company Portal.app" ]; then
/usr/bin/defaults write /Library/Preferences/com.microsoft.autoupdate2 ApplicationsSystem -dict-add "/Applications/Company Portal.app" "{ 'Application ID' = 'IMCP01'; LCID = 1033 ; }"
fi
exit 0

View File

@@ -0,0 +1,190 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_Credentials"
autoload is-at-least
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
FindEntryOpenTech() {
/usr/bin/security find-generic-password -G 'MSOpenTech.ADAL.1' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryOfficeData() {
/usr/bin/security find-generic-password -G 'Microsoft Office Data' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryHelpShift() {
/usr/bin/security find-generic-password -l 'com.helpshift.data_com.microsoft.Outlook' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryRMSCredential() {
/usr/bin/security find-generic-password -l 'MicrosoftOfficeRMSCredential' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryProtectionService() {
/usr/bin/security find-generic-password -l 'MSProtection.framework.service' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryExchange() {
/usr/bin/security find-generic-password -l 'Exchange' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryTeamsIdentity() {
/usr/bin/security find-generic-password -l 'Microsoft Teams Identities Cache' 2> /dev/null 1> /dev/null
echo $?
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Quitting all apps gracefully"
/usr/bin/pkill -HUP 'Microsoft Word'
/usr/bin/pkill -HUP 'Microsoft Excel'
/usr/bin/pkill -HUP 'Microsoft PowerPoint'
/usr/bin/pkill -HUP 'Microsoft Outlook'
/usr/bin/pkill -HUP 'Microsoft OneNote'
KeychainHasLogin=$(/usr/bin/security list-keychains | grep 'login.keychain')
if [ "$KeychainHasLogin" = "" ]; then
echo "Office-Reset: Adding user login keychain to list"
/usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db"
fi
echo "Display list-keychains for logged-in user"
/usr/bin/security list-keychains
echo "Office-Reset: Removing keychain entries"
/usr/bin/security delete-generic-password -s 'OneAuthAccount'
/usr/bin/security delete-internet-password -s 'msoCredentialSchemeADAL'
/usr/bin/security delete-internet-password -s 'msoCredentialSchemeLiveId'
while [[ $(FindEntryOpenTech) -eq 0 ]]; do
/usr/bin/security delete-generic-password -G 'MSOpenTech.ADAL.1'
done
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Cache 2'
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Cache 3'
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Settings 2'
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Settings 3'
/usr/bin/security delete-generic-password -l 'Microsoft Office Ticket Cache'
/usr/bin/security delete-generic-password -l 'Microsoft Office Ticket Cache 2'
/usr/bin/security delete-generic-password -l 'com.microsoft.adalcache'
while [[ $(FindEntryOfficeData) -eq 0 ]]; do
/usr/bin/security delete-generic-password -G 'Microsoft Office Data'
done
/usr/bin/security delete-generic-password -l 'com.microsoft.OutlookCore.Secret'
while [[ $(FindEntryHelpShift) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'com.helpshift.data_com.microsoft.Outlook'
done
while [[ $(FindEntryRMSCredential) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'MicrosoftOfficeRMSCredential'
done
while [[ $(FindEntryProtectionService) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'MSProtection.framework.service'
done
while [[ $(FindEntryExchange) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'Exchange'
done
while [[ $(FindEntryTeamsIdentity) -eq 0 ]]; do
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'Microsoft Teams Identities Cache'
done
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'Teams Safe Storage'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'Microsoft Teams (work or school) Safe Storage'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'teamsIv'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'teamsKey'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'com.microsoft.teams.HockeySDK'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'com.microsoft.teams.helper.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDrive.FinderSync.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDrive.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDriveUpdater.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDriveStandaloneUpdater.HockeySDK'
/usr/bin/security delete-generic-password -l 'OneDrive Standalone Cached Credential Business - Business1'
/usr/bin/security delete-generic-password -l 'OneDrive Standalone Cached Credential'
/usr/bin/security delete-generic-password -s 'com.microsoft.onedrive.cookies'
/usr/bin/security delete-generic-password -s 'OneAuthAccount'
echo "Office-Reset: Removing credential and license files"
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/mip_policy
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/DRM_Evo.plist
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.com.microsoft.oneauth
/bin/rm -f /Library/Preferences/com.microsoft.office.licensingV2.plist.bak
/bin/mv /Library/Preferences/com.microsoft.office.licensingV2.plist /Library/Preferences/com.microsoft.office.licensingV2.backup
/bin/rm -f /Library/Application\ Support/Microsoft/Office365/com.microsoft.Office365.plist
/bin/rm -f /Library/Application\ Support/Microsoft/Office365/com.microsoft.Office365V2.plist
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/com.microsoft.Office365.plist
/bin/mv $HOME/Library/Group\ Containers/UBF8T346G9.Office/com.microsoft.Office365V2.plist $HOME/Library/Group\ Containers/UBF8T346G9.Office/com.microsoft.Office365V2.backup
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/com.microsoft.e0E2OUQxNUY1LTAxOUQtNDQwNS04QkJELTAxQTI5M0JBOTk4O.plist
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/e0E2OUQxNUY1LTAxOUQtNDQwNS04QkJELTAxQTI5M0JBOTk4O
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/com.microsoft.O4kTOBJ0M5ITQxATLEJkQ40SNwQDNtQUOxATL1YUNxQUO2E0e.plist
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/O4kTOBJ0M5ITQxATLEJkQ40SNwQDNtQUOxATL1YUNxQUO2E0e
/bin/rm -rf /Library/Microsoft/Office/Licenses
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/Licenses
/bin/rm -rf $HOME/Library/Containers/com.microsoft.RMS-XPCService
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.Office365ServiceV2
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Word/Data/Library/Application\ Support/Microsoft
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Excel/Data/Library/Application\ Support/Microsoft
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Powerpoint/Data/Library/Application\ Support/Microsoft
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Outlook/Data/Library/Application\ Support/Microsoft
/bin/rm -rf $HOME/Library/Containers/com.microsoft.onenote.mac/Data/Library/Application\ Support/Microsoft
/bin/rm -f $HOME/Library/Preferences/com.microsoft.msa-login-hint.plist
echo "Office-Reset: Changing preferences"
if [ -e "$HOME/Library/Preferences/com.microsoft.office.plist" ]; then
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults delete $HOME/Library/Preferences/com.microsoft.office OfficeActivationEmailAddress
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Preferences/com.microsoft.office OfficeAutoSignIn -bool TRUE
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Preferences/com.microsoft.office HasUserSeenFREDialog -bool TRUE
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Preferences/com.microsoft.office HasUserSeenEnterpriseFREDialog -bool TRUE
fi
if [ -d "$HOME/Library/Containers/com.microsoft.Word/Data/Library/Preferences" ]; then
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Containers/com.microsoft.Word/Data/Library/Preferences/com.microsoft.Word kSubUIAppCompletedFirstRunSetup1507 -bool FALSE
fi
if [ -d "$HOME/Library/Containers/com.microsoft.Excel/Data/Library/Preferences" ]; then
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Containers/com.microsoft.Excel/Data/Library/Preferences/com.microsoft.Excel kSubUIAppCompletedFirstRunSetup1507 -bool FALSE
fi
if [ -d "$HOME/Library/Containers/com.microsoft.Powerpoint/Data/Library/Preferences" ]; then
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Containers/com.microsoft.Powerpoint/Data/Library/Preferences/com.microsoft.Powerpoint kSubUIAppCompletedFirstRunSetup1507 -bool FALSE
fi
if [ -d "$HOME/Library/Containers/com.microsoft.Outlook/Data/Library/Preferences" ]; then
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Containers/com.microsoft.Outlook/Data/Library/Preferences/com.microsoft.Outlook kSubUIAppCompletedFirstRunSetup1507 -bool FALSE
fi
if [ -d "$HOME/Library/Containers/com.microsoft.onenote.mac/Data/Library/Preferences" ]; then
/usr/bin/sudo -u $LoggedInUser /usr/bin/defaults write $HOME/Library/Containers/com.microsoft.onenote.mac/Data/Library/Preferences/com.microsoft.onenote.mac kSubUIAppCompletedFirstRunSetup1507 -bool FALSE
fi
KEYCHAIN_2_PATH=$(find $HOME/Library/Keychains/**/keychain-2.db)
/usr/bin/sqlite3 $KEYCHAIN_2_PATH "DELETE FROM genp WHERE agrp='UBF8T346G9.com.microsoft.identity.universalstorage';"
/bin/rm -f $HOME/Library/Keychains/Microsoft_Entity_Certificates-db
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg
/usr/bin/killall cfprefsd
exit 0

View File

@@ -0,0 +1,62 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_Defender"
autoload is-at-least
SCRIPT_FOLDER=$(/usr/bin/dirname "$0")
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft Defender*'
if [ -e "/Applications/Microsoft Defender.app/Contents/Resources/Tools/uninstall/uninstall" ]; then
$(/Applications/Microsoft\ Defender.app/Contents/Resources/Tools/uninstall/uninstall)
else
/bin/rm -rf /Applications/Microsoft\ Defender.app
fi
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.com.microsoft.wdav
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.wdav.tray
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.wdav.mainux
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.wdav.shim
/bin/rm -rf $HOME/Library/Application\ Support/Microsoft\ Defender\ Helper
/bin/rm -rf $HOME/Library/Caches/com.microsoft.wdav.tray
/bin/rm -rf $HOME/Library/Caches/com.microsoft.wdav.mainux
/bin/rm -rf $HOME/Library/Caches/com.microsoft.wdav.shim
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.wdav.tray
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.wdav.mainux
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.wdav.shim
/bin/rm -rf $HOME/Library/Logs/Microsoft/Defender
/bin/rm -f $HOME/Library/Preferences/UBF8T346G9.com.microsoft.wdav.plist
/usr/sbin/pkgutil --forget com.microsoft.dlp.ux
/usr/sbin/pkgutil --forget com.microsoft.dlp.daemon
/usr/sbin/pkgutil --forget com.microsoft.dlp.agent
exit 0

190
scripts/Office_Excel_Reset.sh Executable file
View File

@@ -0,0 +1,190 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_Excel"
autoload is-at-least
APP_NAME="Microsoft Excel"
APP_GENERATION="2019"
DOWNLOAD_2019="https://go.microsoft.com/fwlink/?linkid=525135"
DOWNLOAD_2016="https://go.microsoft.com/fwlink/?linkid=871750"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
GetPrefValue() { # $1: domain, $2: key
osascript -l JavaScript << EndOfScript
ObjC.import('Foundation');
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('$1').objectForKey('$2'))
EndOfScript
}
GetCustomManifestVersion() {
CHANNEL_NAME=$(GetPrefValue "com.microsoft.autoupdate2" "ChannelName")
if [ "${CHANNEL_NAME}" = "Custom" ]; then
MANIFEST_SERVER=$(GetPrefValue "com.microsoft.autoupdate2" "ManifestServer")
echo "Office-Reset: Found custom ManifestServer ${MANIFEST_SERVER}"
FULL_UPDATER=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409XCEL2019.xml | grep -A1 -m1 'FullUpdaterLocation' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom FullUpdaterLocation ${FULL_UPDATER}"
if [[ "${FULL_UPDATER}" = "https://"* ]]; then
CUSTOM_VERSION=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409XCEL2019-chk.xml | grep -A1 -m1 'Update Version' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom update version ${CUSTOM_VERSION}"
fi
fi
}
RepairApp() {
if [[ "${APP_GENERATION}" == "2016" ]]; then
DOWNLOAD_URL="${DOWNLOAD_2016}"
else
DOWNLOAD_URL="${DOWNLOAD_2019}"
fi
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
GetCustomManifestVersion
if [[ -z "${CUSTOM_VERSION}" ]]; then
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
else
CDN_PKG_URL="${FULL_UPDATER}"
fi
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $CDN_PKG_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $CDN_PKG_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Exiting without removing configuration data"
exit 0
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft Excel'
if [ -d "/Applications/Microsoft Excel.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ Excel.app/Contents/Info.plist CFBundleVersion)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME}"
if ! is-at-least 16.17 $APP_VERSION; then
APP_GENERATION="2016"
fi
if [[ "${APP_GENERATION}" == "2019" ]]; then
if ! is-at-least 16.73 $APP_VERSION && is-at-least 11.0.0 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2019 generation) is ancient. Updating it now"
RepairApp
fi
GetCustomManifestVersion
if [[ "${CUSTOM_VERSION}" ]] && [[ "${APP_VERSION}" != "${CUSTOM_VERSION}" ]]; then
echo "Office-Reset: ${APP_NAME} is ${APP_VERSION} on-disk, but the pinned version has been set to ${CUSTOM_VERSION}. Removing and reinstalling"
/bin/rm -rf /Applications/Microsoft\ Excel.app
RepairApp
fi
fi
if [[ "${APP_GENERATION}" == "2016" ]]; then
if ! is-at-least 16.16 $APP_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2016 generation) is ancient. Updating it now"
RepairApp
fi
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ Excel.app
if [ $? -gt 0 ]; then
CODESIGN_ERROR=$(/usr/bin/codesign -vv --deep /Applications/Microsoft\ Excel.app)
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and reporting error ${CODESIGN_ERROR}"
if [[ "${CODESIGN_ERROR}" = *"OLE.framework"* ]]; then
echo "Office-Reset: Only OLE.framework has been modified. Ignoring the repair"
else
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ Excel.app
RepairApp
fi
else
echo "Office-Reset: Codesign passed successfully"
fi
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -f /Library/Preferences/com.microsoft.Excel.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Excel.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Excel.plist
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Excel
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.Excel
/bin/rm -rf /Applications/.Microsoft\ Excel.app.installBackup
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Startup.localized/Excel
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.xlt
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.xltx
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.xltm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Startup.localized/Excel
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.xlt
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.xltx
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.xltm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/mip_policy
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/ComRPC32
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/TemporaryItems
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg
/usr/bin/security delete-certificate -c 'Microsoft.Office.Excel.ProtectedDataServices'
/bin/rm -rf $TMPDIR/com.microsoft.Excel
exit 0

51
scripts/Office_Factory_Reset.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_Factory"
autoload is-at-least
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Stopping apps and services"
/usr/bin/pkill -9 'Microsoft Word'
/usr/bin/pkill -9 'Microsoft Excel'
/usr/bin/pkill -9 'Microsoft PowerPoint'
/usr/bin/pkill -9 'Microsoft Outlook'
/usr/bin/pkill -9 'Microsoft OneNote'
/usr/bin/pkill -9 'OneDrive'
/usr/bin/pkill -9 'FinderSync'
/usr/bin/pkill -9 'OneDriveStandaloneUpdater'
/usr/bin/pkill -9 'OneDriveUpdater'
/usr/bin/pkill -9 'Microsoft Teams*'
/usr/bin/pkill -9 'Microsoft AutoUpdate'
/usr/bin/pkill -9 'Microsoft Update Assistant'
/usr/bin/pkill -9 'Microsoft AU Daemon'
/usr/bin/pkill -9 'Microsoft AU Bootstrapper'
/usr/bin/pkill -9 'com.microsoft.autoupdate.helper'
/usr/bin/pkill -9 'com.microsoft.autoupdate.helpertool'
/usr/bin/pkill -9 'com.microsoft.autoupdate.bootstrapper.helper'
/usr/bin/pkill -9 'com.microsoft.teams2.launcher'
exit 0

202
scripts/Office_OneDrive_Reset.sh Executable file
View File

@@ -0,0 +1,202 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_OneDrive"
autoload is-at-least
APP_NAME="Microsoft OneDrive"
DOWNLOAD_URL="https://go.microsoft.com/fwlink/?linkid=861011"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
RepairApp() {
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $DOWNLOAD_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'OneDrive'
/usr/bin/pkill -9 'FinderSync'
/usr/bin/pkill -9 'OneDriveStandaloneUpdater'
/usr/bin/pkill -9 'OneDriveUpdater'
if [ -d "/Applications/OneDrive.app" ]; then
APP_VERSION=$(defaults read /Applications/OneDrive.app/Contents/Info.plist CFBundleVersion)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME}"
if ! is-at-least 23154.0 $APP_VERSION && is-at-least 10.15 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} is ancient. Updating it now"
RepairApp
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/OneDrive.app
if [ $? -gt 0 ]; then
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/OneDrive.app
RepairApp
else
echo "Office-Reset: Codesign passed successfully"
fi
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -rf $HOME/Library/Caches/OneDrive
/bin/rm -rf $HOME/Library/Caches/com.microsoft.OneDrive
/bin/rm -rf $HOME/Library/Caches/com.microsoft.OneDriveUpdater
/bin/rm -rf $HOME/Library/Caches/com.microsoft.OneDriveStandaloneUpdater
/bin/rm -rf $HOME/Library/Caches/com.microsoft.SyncReporter
/bin/rm -rf $HOME/Library/Caches/com.microsoft.SharePoint-mac
/bin/rm -f $HOME/Library/Cookies/com.microsoft.OneDrive.binarycookies
/bin/rm -f $HOME/Library/Cookies/com.microsoft.OneDriveUpdater.binarycookies
/bin/rm -f $HOME/Library/Cookies/com.microsoft.OneDriveStandaloneUpdater.binarycookies
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.OneDrive
/bin/rm -f $HOME/Library/HTTPStorages/com.microsoft.OneDrive.binarycookies
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.OneDriveUpdater
/bin/rm -f $HOME/Library/HTTPStorages/com.microsoft.OneDriveUpdater.binarycookies
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.SharePoint-mac
/bin/rm -f $HOME/Library/HTTPStorages/com.microsoft.SharePoint-mac.binarycookies
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.SyncReporter
/bin/rm -f $HOME/Library/HTTPStorages/com.microsoft.SyncReporter.binarycookies
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.OneDriveStandaloneUpdater
/bin/rm -f $HOME/Library/HTTPStorages/com.microsoft.OneDriveStandaloneUpdater.binarycookies
/bin/rm -rf $HOME/Library/WebKit/com.microsoft.OneDrive
/bin/rm -rf $HOME/Library/Containers/com.microsoft.OneDrive-mac
/bin/rm -rf $HOME/Library/Containers/com.microsoft.OneDrive.FinderSync
/bin/rm -rf $HOME/Library/Containers/com.microsoft.OneDrive-mac.FinderSync
/bin/rm -rf $HOME/Library/Containers/com.microsoft.OneDriveLauncher
/bin/rm -rf $HOME/Library/Containers/com.microsoft.OneDrive.FileProvider
/bin/rm -rf $HOME/Library/Logs/OneDrive
/bin/rm -rf /Library/Logs/Microsoft/OneDrive
/bin/rm -rf $HOME/Library/Application\ Support/OneDrive
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.OneDrive
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.OneDriveUpdater
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.OneDriveStandaloneUpdater
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.SharePoint-mac
/bin/rm -rf $HOME/Library/Application\ Support/OneDriveUpdater
/bin/rm -rf $HOME/Library/Application\ Support/OneDriveStandaloneUpdater
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.OneDrive.FinderSync
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.OneDrive.FileProvider
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.OneDriveStandaloneSuite
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.OfficeOneDriveSyncIntegration
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.OneDriveSyncClientSuite
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.Kfm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.OfficeOneDriveSyncIntegration
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.OneDriveStandaloneSuite
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.OneDriveSyncClientSuite
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Kfm
/bin/rm -f $HOME/Library/Preferences/com.microsoft.OneDrive.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.SharePoint-mac.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.OneDriveStandaloneUpdater.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.OneDriveUpdater.plist
/bin/rm -f $HOME/Library/Preferences/UBF8T346G9.OneDriveStandaloneSuite.plist
/bin/rm -f $HOME/Library/Preferences/UBF8T346G9.OfficeOneDriveSyncIntegration.plist
/bin/rm -f /Library/Preferences/com.microsoft.OneDrive.plist
/bin/rm -f /Library/Preferences/com.microsoft.OneDriveStandaloneUpdater.plist
/bin/rm -f /Library/Preferences/com.microsoft.OneDriveUpdater.plist
/bin/rm -f /Library/Preferences/com.microsoft.OneDrive.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.OneDriveStandaloneUpdater.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.OneDriveUpdater.plist
/bin/rm -rf $TMPDIR/com.microsoft.OneDrive
/bin/rm -rf $TMPDIR/com.microsoft.OneDrive.FinderSync
/bin/rm -f $TMPDIR/OneDriveVersion.xml
KeychainHasLogin=$(/usr/bin/security list-keychains | grep 'login.keychain')
if [ "$KeychainHasLogin" = "" ]; then
echo "Office-Reset: Adding user login keychain to list"
/usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db"
fi
echo "Display list-keychains for logged-in user"
/usr/bin/security list-keychains
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDrive.FinderSync.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDrive.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDriveUpdater.HockeySDK'
/usr/bin/security delete-generic-password -l 'com.microsoft.OneDriveStandaloneUpdater.HockeySDK'
/usr/bin/security delete-generic-password -l 'OneDrive Standalone Cached Credential Business - Business1'
/usr/bin/security delete-generic-password -l 'OneDrive Standalone Cached Credential'
/usr/bin/security delete-generic-password -s 'com.microsoft.onedrive.cookies'
/usr/bin/security delete-generic-password -s 'OneAuthAccount'
/usr/bin/security delete-generic-password -l 'com.microsoft.adalcache'
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.com.microsoft.oneauth
KEYCHAIN_2_PATH=$(find $HOME/Library/Keychains/**/keychain-2.db)
/usr/bin/sqlite3 $KEYCHAIN_2_PATH "DELETE FROM genp WHERE agrp='UBF8T346G9.com.microsoft.identity.universalstorage';"
exit 0

View File

@@ -0,0 +1,35 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_OneNote_Data"
autoload is-at-least
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft OneNote'
/bin/rm -rf $HOME/Library/Containers/com.microsoft.onenote.mac
exit 0

180
scripts/Office_OneNote_Reset.sh Executable file
View File

@@ -0,0 +1,180 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_OneNote"
autoload is-at-least
APP_NAME="Microsoft OneNote"
APP_GENERATION="2019"
DOWNLOAD_2019="https://go.microsoft.com/fwlink/?linkid=820886"
DOWNLOAD_2016="https://go.microsoft.com/fwlink/?linkid=871755"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
GetPrefValue() { # $1: domain, $2: key
osascript -l JavaScript << EndOfScript
ObjC.import('Foundation');
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('$1').objectForKey('$2'))
EndOfScript
}
GetCustomManifestVersion() {
CHANNEL_NAME=$(GetPrefValue "com.microsoft.autoupdate2" "ChannelName")
if [ "${CHANNEL_NAME}" = "Custom" ]; then
MANIFEST_SERVER=$(GetPrefValue "com.microsoft.autoupdate2" "ManifestServer")
echo "Office-Reset: Found custom ManifestServer ${MANIFEST_SERVER}"
FULL_UPDATER=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409ONMC2019.xml | grep -A1 -m1 'FullUpdaterLocation' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom FullUpdaterLocation ${FULL_UPDATER}"
if [[ "${FULL_UPDATER}" = "https://"* ]]; then
CUSTOM_VERSION=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409ONMC2019-chk.xml | grep -A1 -m1 'Update Version' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom update version ${CUSTOM_VERSION}"
fi
fi
}
RepairApp() {
if [[ "${APP_GENERATION}" == "2016" ]]; then
DOWNLOAD_URL="${DOWNLOAD_2016}"
else
DOWNLOAD_URL="${DOWNLOAD_2019}"
fi
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
GetCustomManifestVersion
if [[ -z "${CUSTOM_VERSION}" ]]; then
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
else
CDN_PKG_URL="${FULL_UPDATER}"
fi
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $CDN_PKG_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $CDN_PKG_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Exiting without removing configuration data"
exit 0
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft OneNote'
if [ -d "/Applications/Microsoft OneNote.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ OneNote.app/Contents/Info.plist CFBundleVersion)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME}"
if ! is-at-least 16.17 $APP_VERSION; then
APP_GENERATION="2016"
fi
if [[ "${APP_GENERATION}" == "2019" ]]; then
if ! is-at-least 16.73 $APP_VERSION && is-at-least 11.0.0 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2019 generation) is ancient. Updating it now"
RepairApp
fi
GetCustomManifestVersion
if [[ "${CUSTOM_VERSION}" ]] && [[ "${APP_VERSION}" != "${CUSTOM_VERSION}" ]]; then
echo "Office-Reset: ${APP_NAME} is ${APP_VERSION} on-disk, but the pinned version has been set to ${CUSTOM_VERSION}. Removing and reinstalling"
/bin/rm -rf /Applications/Microsoft\ OneNote.app
RepairApp
fi
fi
if [[ "${APP_GENERATION}" == "2016" ]]; then
if ! is-at-least 16.16 $APP_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2016 generation) is ancient. Updating it now"
RepairApp
fi
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ OneNote.app
if [ $? -gt 0 ]; then
CODESIGN_ERROR=$(/usr/bin/codesign -vv --deep /Applications/Microsoft\ OneNote.app)
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and reporting error ${CODESIGN_ERROR}"
if [[ "${CODESIGN_ERROR}" = *"OLE.framework"* ]]; then
echo "Office-Reset: Only OLE.framework has been modified. Ignoring the repair"
else
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ OneNote.app
RepairApp
fi
else
echo "Office-Reset: Codesign passed successfully"
fi
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -f /Library/Preferences/com.microsoft.onenote.mac.plist
/bin/rm -f /Library/Managed Preferences/com.microsoft.onenote.mac.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.onenote.mac.plist
## /bin/rm -rf $HOME/Library/Containers/com.microsoft.onenote.mac
## OneNote Sync Cache is under $HOME/Library/Containers/com.microsoft.onenote.mac/Data/Library/Application\ Support/Microsoft\ User\ Data/
/bin/rm -rf $HOME/Library/Containers/com.microsoft.onenote.mac.shareextension
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.onenote.mac
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.onenote.mac.shareextension
/bin/rm -rf /Applications/.Microsoft\ OneNote.app.installBackup
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T369G9.Office/OneNote
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T369G9.Office/FontCache
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T369G9.Office/TemporaryItems
exit 0

View File

@@ -0,0 +1,38 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_Outlook_Data"
autoload is-at-least
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft Outlook'
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Outlook.plist
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/Outlook
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/OutlookProfile.plist
exit 0

249
scripts/Office_Outlook_Reset.sh Executable file
View File

@@ -0,0 +1,249 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_Outlook"
autoload is-at-least
APP_NAME="Microsoft Outlook"
APP_GENERATION="2019"
DOWNLOAD_2019="https://go.microsoft.com/fwlink/?linkid=525137"
DOWNLOAD_2016="https://go.microsoft.com/fwlink/?linkid=871753"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
GetPrefValue() { # $1: domain, $2: key
osascript -l JavaScript << EndOfScript
ObjC.import('Foundation');
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('$1').objectForKey('$2'))
EndOfScript
}
GetCustomManifestVersion() {
CHANNEL_NAME=$(GetPrefValue "com.microsoft.autoupdate2" "ChannelName")
if [ "${CHANNEL_NAME}" = "Custom" ]; then
MANIFEST_SERVER=$(GetPrefValue "com.microsoft.autoupdate2" "ManifestServer")
echo "Office-Reset: Found custom ManifestServer ${MANIFEST_SERVER}"
FULL_UPDATER=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409OPIM2019.xml | grep -A1 -m1 'FullUpdaterLocation' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom FullUpdaterLocation ${FULL_UPDATER}"
if [[ "${FULL_UPDATER}" = "https://"* ]]; then
CUSTOM_VERSION=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409OPIM2019-chk.xml | grep -A1 -m1 'Update Version' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom update version ${CUSTOM_VERSION}"
fi
fi
}
RepairApp() {
if [[ "${APP_GENERATION}" == "2016" ]]; then
DOWNLOAD_URL="${DOWNLOAD_2016}"
else
DOWNLOAD_URL="${DOWNLOAD_2019}"
fi
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
GetCustomManifestVersion
if [[ -z "${CUSTOM_VERSION}" ]]; then
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
else
CDN_PKG_URL="${FULL_UPDATER}"
fi
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $CDN_PKG_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $CDN_PKG_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Exiting without removing configuration data"
exit 0
}
FindEntryOpenTech() {
/usr/bin/security find-generic-password -G 'MSOpenTech.ADAL.1' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryHelpShift() {
/usr/bin/security find-generic-password -l 'com.helpshift.data_com.microsoft.Outlook' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryRMSCredential() {
/usr/bin/security find-generic-password -l 'MicrosoftOfficeRMSCredential' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryProtectionService() {
/usr/bin/security find-generic-password -l 'MSProtection.framework.service' 2> /dev/null 1> /dev/null
echo $?
}
FindEntryExchange() {
/usr/bin/security find-generic-password -l 'Exchange' 2> /dev/null 1> /dev/null
echo $?
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft Outlook'
if [ -d "/Applications/Microsoft Outlook.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ Outlook.app/Contents/Info.plist CFBundleVersion)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME}"
if ! is-at-least 16.17 $APP_VERSION; then
APP_GENERATION="2016"
fi
if [[ "${APP_GENERATION}" == "2019" ]]; then
if ! is-at-least 16.73 $APP_VERSION && is-at-least 11.0.0 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2019 generation) is ancient. Updating it now"
RepairApp
fi
GetCustomManifestVersion
if [[ "${CUSTOM_VERSION}" ]] && [[ "${APP_VERSION}" != "${CUSTOM_VERSION}" ]]; then
echo "Office-Reset: ${APP_NAME} is ${APP_VERSION} on-disk, but the pinned version has been set to ${CUSTOM_VERSION}. Removing and reinstalling"
/bin/rm -rf /Applications/Microsoft\ Outlook.app
RepairApp
fi
fi
if [[ "${APP_GENERATION}" == "2016" ]]; then
if ! is-at-least 16.16 $APP_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2016 generation) is ancient. Updating it now"
RepairApp
fi
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ Outlook.app
if [ $? -gt 0 ]; then
CODESIGN_ERROR=$(/usr/bin/codesign -vv --deep /Applications/Microsoft\ Outlook.app)
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and reporting error ${CODESIGN_ERROR}"
if [[ "${CODESIGN_ERROR}" = *"OLE.framework"* ]]; then
echo "Office-Reset: Only OLE.framework has been modified. Ignoring the repair"
else
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ Outlook.app
RepairApp
fi
else
echo "Office-Reset: Codesign passed successfully"
fi
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -f /Library/Preferences/com.microsoft.Outlook.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Outlook.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Outlook.plist
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Outlook
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Outlook.CalendarWidget
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.Outlook
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.Outlook.CalendarWidget
/bin/rm -rf /Library/Application\ Support/Microsoft/WebExPlugin
/bin/rm -rf /Library/Application\ Support/Microsoft/ZoomOutlookPlugin
/bin/rm -rf /Users/Shared/ZoomOutlookPlugin
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Startup.localized/Word/NormalEmail.dotm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Startup.localized/Word/NormalEmail.dotm
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/DRM_Evo.plist
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/mip_policy
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/FontCache
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/ComRPC32
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/TemporaryItems
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/Microsoft\ Office\ ACL*
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg
/bin/rm -rf $TMPDIR/com.microsoft.Outlook
/bin/rm -rf /Applications/.Microsoft\ Outlook.app.installBackup
KeychainHasLogin=$(/usr/bin/security list-keychains | grep 'login.keychain')
if [ "$KeychainHasLogin" = "" ]; then
echo "Office-Reset: Adding user login keychain to list"
/usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db"
fi
echo "Display list-keychains for logged-in user"
/usr/bin/security list-keychains
/usr/bin/security delete-internet-password -s 'msoCredentialSchemeADAL'
/usr/bin/security delete-internet-password -s 'msoCredentialSchemeLiveId'
while [[ $(FindEntryOpenTech) -eq 0 ]]; do
/usr/bin/security delete-generic-password -G 'MSOpenTech.ADAL.1'
done
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Cache 2'
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Cache 3'
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Settings 2'
/usr/bin/security delete-generic-password -l 'Microsoft Office Identities Settings 3'
/usr/bin/security delete-generic-password -l 'Microsoft Office Ticket Cache'
/usr/bin/security delete-generic-password -l 'Microsoft Office Ticket Cache 2'
/usr/bin/security delete-generic-password -l 'com.microsoft.adalcache'
/usr/bin/security delete-generic-password -l 'com.microsoft.OutlookCore.Secret'
while [[ $(FindEntryHelpShift) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'com.helpshift.data_com.microsoft.Outlook'
done
while [[ $(FindEntryRMSCredential) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'MicrosoftOfficeRMSCredential'
done
while [[ $(FindEntryProtectionService) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'MSProtection.framework.service'
done
while [[ $(FindEntryExchange) -eq 0 ]]; do
/usr/bin/security delete-generic-password -l 'Exchange'
done
exit 0

View File

@@ -0,0 +1,195 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_PowerPoint"
autoload is-at-least
APP_NAME="Microsoft PowerPoint"
APP_GENERATION="2019"
DOWNLOAD_2019="https://go.microsoft.com/fwlink/?linkid=525136"
DOWNLOAD_2016="https://go.microsoft.com/fwlink/?linkid=871751"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
GetPrefValue() { # $1: domain, $2: key
osascript -l JavaScript << EndOfScript
ObjC.import('Foundation');
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('$1').objectForKey('$2'))
EndOfScript
}
GetCustomManifestVersion() {
CHANNEL_NAME=$(GetPrefValue "com.microsoft.autoupdate2" "ChannelName")
if [ "${CHANNEL_NAME}" = "Custom" ]; then
MANIFEST_SERVER=$(GetPrefValue "com.microsoft.autoupdate2" "ManifestServer")
echo "Office-Reset: Found custom ManifestServer ${MANIFEST_SERVER}"
FULL_UPDATER=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409PPT32019.xml | grep -A1 -m1 'FullUpdaterLocation' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom FullUpdaterLocation ${FULL_UPDATER}"
if [[ "${FULL_UPDATER}" = "https://"* ]]; then
CUSTOM_VERSION=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409PPT32019-chk.xml | grep -A1 -m1 'Update Version' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom update version ${CUSTOM_VERSION}"
fi
fi
}
RepairApp() {
if [[ "${APP_GENERATION}" == "2016" ]]; then
DOWNLOAD_URL="${DOWNLOAD_2016}"
else
DOWNLOAD_URL="${DOWNLOAD_2019}"
fi
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
GetCustomManifestVersion
if [[ -z "${CUSTOM_VERSION}" ]]; then
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
else
CDN_PKG_URL="${FULL_UPDATER}"
fi
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $CDN_PKG_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $CDN_PKG_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Exiting without removing configuration data"
exit 0
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft PowerPoint'
if [ -d "/Applications/Microsoft PowerPoint.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ PowerPoint.app/Contents/Info.plist CFBundleVersion)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME}"
if ! is-at-least 16.17 $APP_VERSION; then
APP_GENERATION="2016"
fi
if [[ "${APP_GENERATION}" == "2019" ]]; then
if ! is-at-least 16.73 $APP_VERSION && is-at-least 11.0.0 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2019 generation) is ancient. Updating it now"
RepairApp
fi
GetCustomManifestVersion
if [[ "${CUSTOM_VERSION}" ]] && [[ "${APP_VERSION}" != "${CUSTOM_VERSION}" ]]; then
echo "Office-Reset: ${APP_NAME} is ${APP_VERSION} on-disk, but the pinned version has been set to ${CUSTOM_VERSION}. Removing and reinstalling"
/bin/rm -rf /Applications/Microsoft\ PowerPoint.app
RepairApp
fi
fi
if [[ "${APP_GENERATION}" == "2016" ]]; then
if ! is-at-least 16.16 $APP_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2016 generation) is ancient. Updating it now"
RepairApp
fi
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ PowerPoint.app
if [ $? -gt 0 ]; then
CODESIGN_ERROR=$(/usr/bin/codesign -vv --deep /Applications/Microsoft\ PowerPoint.app)
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and reporting error ${CODESIGN_ERROR}"
if [[ "${CODESIGN_ERROR}" = *"OLE.framework"* ]]; then
echo "Office-Reset: Only OLE.framework has been modified. Ignoring the repair"
else
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ PowerPoint.app
RepairApp
fi
else
echo "Office-Reset: Codesign passed successfully"
fi
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -f /Library/Preferences/com.microsoft.Powerpoint.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Powerpoint.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Powerpoint.plist
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Powerpoint
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.Powerpoint
/bin/rm -rf /Applications/.Microsoft\ PowerPoint.app.installBackup
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Startup.localized/PowerPoint
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.pot
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.potx
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.potm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Startup.localized/PowerPoint
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.pot
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.potx
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.potm
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Add-Ins/*.ppam
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Add-Ins/*.ppam
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Themes
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Themes
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/mip_policy
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/FontCache
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/ComRPC32
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/TemporaryItems
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/Microsoft\ Office\ ACL*
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg
/bin/rm -rf $TMPDIR/com.microsoft.Powerpoint
exit 0

170
scripts/Office_Remove.sh Executable file
View File

@@ -0,0 +1,170 @@
#!/bin/zsh
echo "Office-Reset: Starting preinstall for Remove_Office"
autoload is-at-least
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Stopping services"
/usr/bin/pkill -9 'Microsoft Word'
/usr/bin/pkill -9 'Microsoft Excel'
/usr/bin/pkill -9 'Microsoft PowerPoint'
/usr/bin/pkill -9 'Microsoft Outlook'
/usr/bin/pkill -9 'Microsoft OneNote'
/usr/bin/pkill -9 'OneDrive'
/usr/bin/pkill -9 'OneDrive Finder Integration'
/usr/bin/pkill -9 'OneDriveStandaloneUpdater'
/usr/bin/pkill -9 'OneDriveUpdater'
/usr/bin/pkill -9 'Microsoft Teams*'
/usr/bin/pkill -9 'Microsoft AutoUpdate'
/usr/bin/pkill -9 'Microsoft Update Assistant'
/usr/bin/pkill -9 'Microsoft AU Daemon'
/usr/bin/pkill -9 'Microsoft AU Bootstrapper'
/usr/bin/pkill -9 'com.microsoft.autoupdate.helper'
/usr/bin/pkill -9 'com.microsoft.autoupdate.helpertool'
/usr/bin/pkill -9 'com.microsoft.autoupdate.bootstrapper.helper'
/bin/launchctl stop /Library/LaunchAgents/com.microsoft.update.agent.plist
/bin/launchctl stop /Library/LaunchAgents/com.microsoft.autoupdate.helper.plist
/bin/launchctl stop /Library/LaunchAgents/com.microsoft.OneDriveStandaloneUpdater.plist
/bin/launchctl stop /Library/LaunchAgents/com.microsoft.SyncReporter.plist
/bin/launchctl stop /Library/LaunchDaemons/com.microsoft.autoupdate.helper
/bin/launchctl stop /Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist
/bin/launchctl stop /Library/LaunchDaemons/com.microsoft.OneDriveUpdaterDaemon.plist
/bin/launchctl stop /Library/LaunchDaemons/com.microsoft.teams.TeamsUpdaterDaemon.plist
/bin/launchctl unload /Library/LaunchAgents/com.microsoft.update.agent.plist
/bin/launchctl unload /Library/LaunchAgents/com.microsoft.autoupdate.helper.plist
/bin/launchctl unload /Library/LaunchAgents/com.microsoft.OneDriveStandaloneUpdater.plist
/bin/launchctl unload /Library/LaunchDaemons/com.microsoft.autoupdate.helper
/bin/launchctl unload /Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist
/bin/launchctl unload /Library/LaunchDaemons/com.microsoft.OneDriveUpdaterDaemon.plist
/bin/launchctl unload /Library/LaunchDaemons/com.microsoft.teams.TeamsUpdaterDaemon.plist
echo "Office-Reset: Removing apps"
/bin/rm -rf /Applications/Microsoft\ Word.app
/bin/rm -rf /Applications/Microsoft\ Excel.app
/bin/rm -rf /Applications/Microsoft\ PowerPoint.app
/bin/rm -rf /Applications/Microsoft\ Outlook.app
/bin/rm -rf /Applications/Microsoft\ OneNote.app
/bin/rm -rf /Applications/OneDrive.app
/bin/rm -rf /Applications/Microsoft\ Teams.app
/bin/rm -rf /Applications/Microsoft\ Teams\ classic.app
/bin/rm -rf /Applications/Microsoft\ Teams\ \(work\ or\ school\).app
/bin/rm -rf /Applications/CodeSignSummary-*.md
echo "Office-Reset: Removing app data"
/bin/rm -rf /Library/Application\ Support/Microsoft/MAU2.0
/bin/rm -rf /Library/Application\ Support/Microsoft/MERP2.0
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365
/bin/rm -rf $HOME/Library/Application\ Support/Microsoft
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.errorreporting
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.com.microsoft.oneauth
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.Office
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.ms
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.OfficeOsfWebHost
/bin/rm -f /Library/LaunchAgents/com.microsoft.update.agent.plist
/bin/rm -f /Library/LaunchAgents/com.microsoft.OneDriveStandaloneUpdater.plist
/bin/rm -f /Library/LaunchAgents/com.microsoft.SyncReporter.plist
/bin/rm -f /Library/LaunchDaemons/com.microsoft.autoupdate.helper.plist
/bin/rm -f /Library/LaunchDaemons/com.microsoft.office.licensingV2.helper.plist
/bin/rm -f /Library/LaunchDaemons/com.microsoft.OneDriveStandaloneUpdaterDaemon.plist
/bin/rm -f /Library/LaunchDaemons/com.microsoft.OneDriveUpdaterDaemon.plist
/bin/rm -f /Library/LaunchDaemons/com.microsoft.teams.TeamsUpdaterDaemon.plist
/bin/rm -f /Library/PrivilegedHelperTools/com.microsoft.autoupdate.helper
/bin/rm -f /Library/PrivilegedHelperTools/com.microsoft.autoupdate.helpertool
/bin/rm -f /Library/PrivilegedHelperTools/com.microsoft.office.licensingV2.helper
/bin/rm -rf /Library/Audio/Plug-Ins/HAL/MSTeamsAudioDevice.driver
/bin/rm -rf /Library/Logs/Microsoft
/bin/rm -rf $HOME/Library/Logs/Microsoft
# OneDriveFolder=$(/bin/ls "$HOME" | grep 'OneDrive' --max-count=1)
# if [ "$OneDriveFolder" != "" ]; then
# IsOneDrive=$(/usr/bin/xattr "$HOME/$OneDriveFolder" | grep 'com.apple.fileutil.SyncRootProviderRootContextList')
# if [ "$IsOneDrive" = "com.apple.fileutil.SyncRootProviderRootContextList" ]; then
# echo "Office-Reset: Removing OneDrive folder $OneDriveFolder"
# /bin/rm -rf "$HOME/$OneDriveFolder"
# fi
# fi
/bin/rm -f $HOME/Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.autoupdate.fba.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.shared.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.office.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Word.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Excel.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Powerpoint.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Outlook.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.onenote.mac.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.OneDrive-mac.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.OneDrive.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.teams.plist
/bin/rm -f /Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f /Library/Preferences/com.microsoft.autoupdate.fba.plist
/bin/rm -f /Library/Preferences/com.microsoft.shared.plist
/bin/rm -f /Library/Preferences/com.microsoft.office.plist
/bin/rm -f /Library/Preferences/com.microsoft.Word.plist
/bin/rm -f /Library/Preferences/com.microsoft.Excel.plist
/bin/rm -f /Library/Preferences/com.microsoft.Powerpoint.plist
/bin/rm -f /Library/Preferences/com.microsoft.Outlook.plist
/bin/rm -f /Library/Preferences/com.microsoft.onenote.mac.plist
/bin/rm -f /Library/Preferences/com.microsoft.OneDrive-mac.plist
/bin/rm -f /Library/Preferences/com.microsoft.OneDrive.plist
/bin/rm -f /Library/Preferences/com.microsoft.teams.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.shared.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.office.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Word.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Excel.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Powerpoint.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Outlook.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.onenote.mac.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.OneDrive-mac.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.OneDrive.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.teams.plist
/bin/rm -f /var/root/Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f /var/root/Library/Preferences/com.microsoft.autoupdate.fba.plist
/bin/rm -rf $HOME/Library/Caches/com.microsoft.autoupdate2
/bin/rm -rf $HOME/Library/Caches/com.microsoft.autoupdate.fba
/bin/rm -rf $HOME/Library/Caches/Microsoft
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.ms
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.OfficeOsfWebHost
/bin/rm -rf $HOME/Library/Group\ Containers/group.com.microsoft
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.com.microsoft.oneauth
/bin/rm -rf $HOME/Library/Containers/com.microsoft.errorreporting
/bin/rm -rf $HOME/Library/Containers/com.microsoft.netlib.shipassertprocess
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Office365ServiceV2
/bin/rm -rf $HOME/Library/Containers/com.microsoft.RMS-XPCService
exit 0

80
scripts/Office_Remove_2.sh Executable file
View File

@@ -0,0 +1,80 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_Office"
autoload is-at-least
SCRIPT_FOLDER=$(/usr/bin/dirname "$0")
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Removing package receipts"
/usr/sbin/pkgutil --forget com.microsoft.Word
/usr/sbin/pkgutil --forget com.microsoft.Excel
/usr/sbin/pkgutil --forget com.microsoft.Powerpoint
/usr/sbin/pkgutil --forget com.microsoft.Outlook
/usr/sbin/pkgutil --forget com.microsoft.onenote.mac
/usr/sbin/pkgutil --forget com.microsoft.OneDrive-mac
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_Word.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_Excel.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_PowerPoint.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_Outlook.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_OneNote.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_AutoUpdate.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_AU_Bootstrapper.app
/usr/sbin/pkgutil --forget com.microsoft.package.com.microsoft.office.licensingV2.helper
/usr/sbin/pkgutil --forget com.microsoft.package.Proofing_Tools
/usr/sbin/pkgutil --forget com.microsoft.package.Fonts
/usr/sbin/pkgutil --forget com.microsoft.package.DFonts
/usr/sbin/pkgutil --forget com.microsoft.package.Frameworks
/usr/sbin/pkgutil --forget com.microsoft.pkg.licensing
/usr/sbin/pkgutil --forget com.microsoft.pkg.licensing.volume
/usr/sbin/pkgutil --forget com.microsoft.office.licensingV2.helper
/usr/sbin/pkgutil --forget com.microsoft.teams
/usr/sbin/pkgutil --forget com.microsoft.teams2
/usr/sbin/pkgutil --forget com.microsoft.MSTeamsAudioDevice
/usr/sbin/pkgutil --forget com.microsoft.wdav
/usr/sbin/pkgutil --forget com.microsoft.OneDrive
/bin/rm -f /Library/Preferences/com.microsoft.office.licensingV2.backup
/bin/rm -f /Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.autoupdate2.plist
/bin/rm -f $HOME/Library/Cookies/com.microsoft.OneDrive.binarycookies
/bin/rm -f $HOME/Library/Cookies/com.microsoft.OneDriveUpdater.binarycookies
/bin/rm -f $HOME/Library/Cookies/com.microsoft.OneDriveStandaloneUpdater.binarycookies
/bin/rm -f $HOME/Library/Cookies/com.microsoft.teams.binarycookies
/bin/rm -rf /Library/Logs/Microsoft
/bin/rm -rf /Library/Application\ Support/Microsoft
/bin/rm -rf /Users/Shared/OnDemandInstaller
exit 0

View File

@@ -0,0 +1,56 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_SkypeForBusiness"
autoload is-at-least
SCRIPT_FOLDER=$(/usr/bin/dirname "$0")
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Skype for Business'
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.SkypeForBusiness
/bin/rm -rf $HOME/Library/Containers/com.microsoft.SkypeForBusiness
/bin/rm -rf $HOME/Library/Preferences/com.microsoft.OutlookSkypeIntegration.plist
/bin/rm -f /Library/Preferences/com.microsoft.SkypeForBusiness.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.SkypeForBusiness.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.SkypeForBusiness.plist
KeychainHasLogin=$(/usr/bin/security list-keychains | grep 'login.keychain')
if [ "$KeychainHasLogin" = "" ]; then
echo "Office-Reset: Adding user login keychain to list"
/usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db"
fi
/usr/bin/security delete-generic-password -l 'com.microsoft.SkypeForBusiness.HockeySDK'
/usr/bin/security delete-generic-password -l 'Skype for Business'
/bin/rm -rf /Applications/Skype\ for\ Business.app
/usr/sbin/pkgutil --forget com.microsoft.package.Microsoft_AU_Bootstrapper.app
/usr/sbin/pkgutil --forget com.microsoft.SkypeForBusiness
exit 0

208
scripts/Office_Teams_Reset.sh Executable file
View File

@@ -0,0 +1,208 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_Teams"
autoload is-at-least
APP_NAME="Microsoft Teams"
DOWNLOAD_URL_TEAMS10="https://go.microsoft.com/fwlink/?linkid=869428"
DOWNLOAD_URL_TEAMS21="https://go.microsoft.com/fwlink/?linkid=2249065"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
RepairApp() {
DOWNLOAD_URL="$1"
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $DOWNLOAD_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
}
FindEntryTeamsIdentity() {
/usr/bin/security find-generic-password -l 'Microsoft Teams Identities Cache' 2> /dev/null 1> /dev/null
echo $?
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
/usr/bin/pkill -9 'Microsoft Teams*'
if [ -d "/Applications/Microsoft Teams.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ Teams.app/Contents/Info.plist CFBundleVersion)
APP_BUNDLEID=$(defaults read /Applications/Microsoft\ Teams.app/Contents/Info.plist CFBundleIdentifier)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME} with bundle ID ${APP_BUNDLEID}"
if [[ "${APP_BUNDLEID}" == "com.microsoft.teams" ]]; then
if ! is-at-least 611156.0 $APP_VERSION && is-at-least 10.15 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} is ancient. Updating it now"
RepairApp "$DOWNLOAD_URL_TEAMS10"
fi
fi
fi
if [ -d "/Applications/Microsoft Teams classic.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ Teams\ classic.app/Contents/Info.plist CFBundleVersion)
APP_BUNDLEID=$(defaults read /Applications/Microsoft\ Teams.app/Contents/Info.plist CFBundleIdentifier)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME} with bundle ID ${APP_BUNDLEID}"
if ! is-at-least 627656.0 $APP_VERSION && is-at-least 10.15 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} is ancient. Updating it now"
RepairApp "$DOWNLOAD_URL_TEAMS10"
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ Teams\ classic.app
if [ $? -gt 0 ]; then
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ Teams\ classic.app
RepairApp "$DOWNLOAD_URL_TEAMS10"
else
echo "Office-Reset: Codesign passed successfully"
fi
fi
if [ -d "/Applications/Microsoft Teams (work or school).app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ Teams\ \(work\ or\ school\).app/Contents/Info.plist CFBundleVersion)
APP_BUNDLEID=$(defaults read /Applications/Microsoft\ Teams\ \(work\ or\ school\).app/Contents/Info.plist CFBundleIdentifier)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME} with bundle ID ${APP_BUNDLEID}"
if ! is-at-least 23247.0 $APP_VERSION && is-at-least 10.15 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} is ancient. Updating it now"
RepairApp "$DOWNLOAD_URL_TEAMS21"
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ Teams\ \(work\ or\ school\).app
if [ $? -gt 0 ]; then
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ Teams\ \(work\ or\ school\).app
RepairApp "$DOWNLOAD_URL_TEAMS21"
else
echo "Office-Reset: Codesign passed successfully"
fi
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -rf $HOME/Library/Application\ Support/Teams
/bin/rm -rf $HOME/Library/Application\ Support/Microsoft/Teams
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.teams
/bin/rm -rf $HOME/Library/Application\ Support/com.microsoft.teams.helper
/bin/rm -rf $HOME/Library/Application\ Scripts/UBF8T346G9.com.microsoft.teams
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.teams2
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.teams2.launcher
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.teams2.notificationcenter
/bin/rm -rf $HOME/Library/Caches/com.microsoft.teams
/bin/rm -rf $HOME/Library/Caches/com.microsoft.teams.helper
/bin/rm -f $HOME/Library/Cookies/com.microsoft.teams.binarycookies
/bin/rm -f $HOME/Library/HTTPStorages/com.microsoft.teams.binarycookies
/bin/rm -rf $HOME/Library/HTTPStorages/com.microsoft.teams
/bin/rm -rf $HOME/Library/Logs/Microsoft\ Teams
/bin/rm -rf $HOME/Library/Logs/Microsoft\ Teams\ Helper
/bin/rm -rf $HOME/Library/Logs/Microsoft\ Teams\ Helper \(Renderer\)
/bin/rm -rf $HOME/Library/Saved\ Application\ State/com.microsoft.teams.savedState
/bin/rm -rf $HOME/Library/WebKit/com.microsoft.teams
/bin/rm -rf $HOME/Library/Containers/com.microsoft.teams2
/bin/rm -rf $HOME/Library/Containers/com.microsoft.teams2.launcher
/bin/rm -rf $HOME/Library/Containers/com.microsoft.teams2.notificationcenter
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.com.microsoft.teams
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.com.microsoft.oneauth
/bin/rm -rf /Library/Application\ Support/TeamsUpdaterDaemon
/bin/rm -rf /Library/Application\ Support/Microsoft/TeamsUpdaterDaemon
/bin/rm -rf /Library/Application\ Support/Teams
/bin/rm -f $HOME/Library/Preferences/com.microsoft.teams.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.teams.plist
/bin/rm -f /Library/Preferences/com.microsoft.teams.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.teams.helper.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.teams.helper.plist
/bin/rm -f /Library/Preferences/com.microsoft.teams.helper.plist
/bin/rm -rf $TMPDIR/com.microsoft.teams
/bin/rm -rf $TMPDIR/com.microsoft.teams\ Crashes
/bin/rm -rf $TMPDIR/Teams
/bin/rm -rf $TMPDIR/Microsoft\ Teams\ Helper\ \(Renderer\)
/bin/rm -rf $TMPDIR/v8-compile-cache-501
/bin/rm -rf /Library/Logs/Microsoft/Teams
KeychainHasLogin=$(/usr/bin/sudo -u $LoggedInUser /usr/bin/security list-keychains | grep 'login.keychain')
if [ "$KeychainHasLogin" = "" ]; then
echo "Office-Reset: Adding user login keychain to list"
/usr/bin/sudo -u $LoggedInUser /usr/bin/security list-keychains -s "$HOME/Library/Keychains/login.keychain-db"
fi
echo "Display list-keychains for logged-in user"
/usr/bin/sudo -u $LoggedInUser /usr/bin/security list-keychains
while [[ $(FindEntryTeamsIdentity) -eq 0 ]]; do
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'Microsoft Teams Identities Cache'
done
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'Teams Safe Storage'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'Microsoft Teams (work or school) Safe Storage'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'teamsIv'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'teamsKey'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'com.microsoft.teams.HockeySDK'
/usr/bin/sudo -u $LoggedInUser /usr/bin/security delete-generic-password -l 'com.microsoft.teams.helper.HockeySDK'
exit 0

190
scripts/Office_Word_Reset.sh Executable file
View File

@@ -0,0 +1,190 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Reset_Word"
autoload is-at-least
APP_NAME="Microsoft Word"
APP_GENERATION="2019"
DOWNLOAD_2019="https://go.microsoft.com/fwlink/?linkid=525134"
DOWNLOAD_2016="https://go.microsoft.com/fwlink/?linkid=871748"
OS_VERSION=$(sw_vers -productVersion)
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
GetPrefValue() { # $1: domain, $2: key
osascript -l JavaScript << EndOfScript
ObjC.import('Foundation');
ObjC.unwrap($.NSUserDefaults.alloc.initWithSuiteName('$1').objectForKey('$2'))
EndOfScript
}
GetCustomManifestVersion() {
CHANNEL_NAME=$(GetPrefValue "com.microsoft.autoupdate2" "ChannelName")
if [ "${CHANNEL_NAME}" = "Custom" ]; then
MANIFEST_SERVER=$(GetPrefValue "com.microsoft.autoupdate2" "ManifestServer")
echo "Office-Reset: Found custom ManifestServer ${MANIFEST_SERVER}"
FULL_UPDATER=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409MSWD2019.xml | grep -A1 -m1 'FullUpdaterLocation' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom FullUpdaterLocation ${FULL_UPDATER}"
if [[ "${FULL_UPDATER}" = "https://"* ]]; then
CUSTOM_VERSION=$(/usr/bin/nscurl --location ${MANIFEST_SERVER}/0409MSWD2019-chk.xml | grep -A1 -m1 'Update Version' | grep 'string' | sed -e 's,.*<string>\([^<]*\)</string>.*,\1,g')
echo "Office-Reset: Found custom update version ${CUSTOM_VERSION}"
fi
fi
}
RepairApp() {
if [[ "${APP_GENERATION}" == "2016" ]]; then
DOWNLOAD_URL="${DOWNLOAD_2016}"
else
DOWNLOAD_URL="${DOWNLOAD_2019}"
fi
DOWNLOAD_FOLDER="/Users/Shared/OnDemandInstaller/"
if [ -d "$DOWNLOAD_FOLDER" ]; then
rm -rf "$DOWNLOAD_FOLDER"
fi
mkdir -p "$DOWNLOAD_FOLDER"
GetCustomManifestVersion
if [[ -z "${CUSTOM_VERSION}" ]]; then
CDN_PKG_URL=$(/usr/bin/nscurl --location --head $DOWNLOAD_URL --dump-header - | awk '/Location/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
else
CDN_PKG_URL="${FULL_UPDATER}"
fi
echo "Office-Reset: Package to download is ${CDN_PKG_URL}"
CDN_PKG_NAME=$(/usr/bin/basename "${CDN_PKG_URL}")
CDN_PKG_SIZE=$(/usr/bin/nscurl --location --head $CDN_PKG_URL --dump-header - | awk '/Content-Length/' | cut -d ' ' -f2 | tail -1 | awk '{$1=$1};1')
CDN_PKG_MB=$(/bin/expr ${CDN_PKG_SIZE} / 1000 / 1000)
echo "Office-Reset: Download package is ${CDN_PKG_MB} megabytes in size"
echo "Office-Reset: Starting ${APP_NAME} package download"
/usr/bin/nscurl --background --download --large-download --location --download-directory $DOWNLOAD_FOLDER $CDN_PKG_URL
echo "Office-Reset: Finished package download"
LOCAL_PKG_SIZE=$(cd "${DOWNLOAD_FOLDER}" && stat -qf%z "${CDN_PKG_NAME}")
if [[ "${LOCAL_PKG_SIZE}" == "${CDN_PKG_SIZE}" ]]; then
echo "Office-Reset: Downloaded package is wholesome"
else
echo "Office-Reset: Downloaded package is malformed. Local file size: ${LOCAL_PKG_SIZE}"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
LOCAL_PKG_SIGNING=$(/usr/sbin/pkgutil --check-signature ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} | awk '/Developer ID Installer'/ | cut -d ':' -f 2 | awk '{$1=$1};1')
if [[ "${LOCAL_PKG_SIGNING}" == "Microsoft Corporation (UBF8T346G9)" ]]; then
echo "Office-Reset: Downloaded package is signed by Microsoft"
else
echo "Office-Reset: Downloaded package is not signed by Microsoft"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Starting package install"
sudo /usr/sbin/installer -pkg ${DOWNLOAD_FOLDER}${CDN_PKG_NAME} -target /
if [ $? -eq 0 ]; then
echo "Office-Reset: Package installed successfully"
else
echo "Office-Reset: Package installation failed"
echo "Office-Reset: Please manually download and install ${APP_NAME} from ${CDN_PKG_URL}"
exit 0
fi
echo "Office-Reset: Exiting without removing configuration data"
exit 0
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME; Temp Folder: $TMPDIR"
/usr/bin/pkill -9 'Microsoft Word'
if [ -d "/Applications/Microsoft Word.app" ]; then
APP_VERSION=$(defaults read /Applications/Microsoft\ Word.app/Contents/Info.plist CFBundleVersion)
echo "Office-Reset: Found version ${APP_VERSION} of ${APP_NAME}"
if ! is-at-least 16.17 $APP_VERSION; then
APP_GENERATION="2016"
fi
if [[ "${APP_GENERATION}" == "2019" ]]; then
if ! is-at-least 16.73 $APP_VERSION && is-at-least 11.0.0 $OS_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2019 generation) is ancient. Updating it now"
RepairApp
fi
GetCustomManifestVersion
if [[ "${CUSTOM_VERSION}" ]] && [[ "${APP_VERSION}" != "${CUSTOM_VERSION}" ]]; then
echo "Office-Reset: ${APP_NAME} is ${APP_VERSION} on-disk, but the pinned version has been set to ${CUSTOM_VERSION}. Removing and reinstalling"
/bin/rm -rf /Applications/Microsoft\ Word.app
RepairApp
fi
fi
if [[ "${APP_GENERATION}" == "2016" ]]; then
if ! is-at-least 16.16 $APP_VERSION; then
echo "Office-Reset: The installed version of ${APP_NAME} (2016 generation) is ancient. Updating it now"
RepairApp
fi
fi
echo "Office-Reset: Checking the app bundle for corruption"
/usr/bin/codesign -vv --deep /Applications/Microsoft\ Word.app
if [ $? -gt 0 ]; then
CODESIGN_ERROR=$(/usr/bin/codesign -vv --deep /Applications/Microsoft\ Word.app)
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and reporting error ${CODESIGN_ERROR}"
if [[ "${CODESIGN_ERROR}" = *"OLE.framework"* ]]; then
echo "Office-Reset: Only OLE.framework has been modified. Ignoring the repair"
else
echo "Office-Reset: The ${APP_NAME} app bundle is damaged and will be removed and reinstalled"
/bin/rm -rf /Applications/Microsoft\ Word.app
RepairApp
fi
else
echo "Office-Reset: Codesign passed successfully"
fi
else
echo "Office-Reset: ${APP_NAME} was not found in the default location"
fi
echo "Office-Reset: Removing configuration data for ${APP_NAME}"
/bin/rm -f /Library/Preferences/com.microsoft.Word.plist
/bin/rm -f /Library/Managed\ Preferences/com.microsoft.Word.plist
/bin/rm -f $HOME/Library/Preferences/com.microsoft.Word.plist
/bin/rm -rf $HOME/Library/Containers/com.microsoft.Word
/bin/rm -rf $HOME/Library/Application\ Scripts/com.microsoft.Word
/bin/rm -rf /Applications/.Microsoft\ Word.app.installBackup
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Startup.localized/Word
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.dot
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.dotx
/bin/rm -rf /Library/Application\ Support/Microsoft/Office365/User\ Content.localized/Templates.localized/*.dotm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Startup.localized/Word
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.dot
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.dotx
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/User\ Content.localized/Templates.localized/*.dotm
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/mip_policy
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/FontCache
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/ComRPC32
/bin/rm -rf $HOME/Library/Group\ Containers/UBF8T346G9.Office/TemporaryItems
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/Microsoft\ Office\ ACL*
/bin/rm -f $HOME/Library/Group\ Containers/UBF8T346G9.Office/MicrosoftRegistrationDB.reg
/bin/rm -rf $TMPDIR/com.microsoft.Word
exit 0

58
scripts/WebExPT_Remove.sh Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_WebExPT"
autoload is-at-least
APP_NAME="WebEx Productivity Tools"
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Running native uninstall routine for ${APP_NAME}"
/Applications/WebEx\ Productivity\ Tools/Uninstall/Contents/MacOS/Uninstall
echo "Office-Reset: Stopping WebEx agent"
/bin/launchctl stop /Library/LaunchAgents/com.webex.pluginagent.plist
/bin/launchctl unload /Library/LaunchAgents/com.webex.pluginagent.plist
echo "Office-Reset: Removing agent configuration for ${APP_NAME}"
/bin/rm -rf $HOME/Library/Application\ Support/Cisco/Webex\ Plugin
/bin/rm -rf $HOME/Library/Application\ Support/Cisco/Webex\ Meetings
/bin/rm -rf $HOME/Library/Caches/com.cisco.webex.pluginservice
/bin/rm -rf $HOME/Library/Caches/com.cisco.webex.webexmta
/bin/rm -rf $HOME/Library/Group\ Containers/group.com.cisco.webex.meetings
/bin/rm -rf $HOME/Library/Logs/PT
/bin/rm -rf $HOME/Library/Logs/webexmta
/bin/rm -f $HOME/Library/Preferences/com.cisco.webex.pluginservice.plist
echo "Office-Reset: Removing binaries for ${APP_NAME}"
/bin/rm -rf /Library/Application\ Support/Microsoft/WebExPlugin
/bin/rm -rf /Library/ScriptingAdditions/WebexScriptAddition.osax
/bin/rm -rf /Users/Shared/WebExPlugin
/bin/rm -rf /Applications/WebEx\ Productivity\ Tools
/usr/sbin/pkgutil --forget olp.mac.webex.com
exit 0

57
scripts/ZoomPlugin_Remove.sh Executable file
View File

@@ -0,0 +1,57 @@
#!/bin/zsh
echo "Office-Reset: Starting postinstall for Remove_ZoomPlugin"
autoload is-at-least
APP_NAME="Zoom Outlook Plugin"
GetLoggedInUser() {
LOGGEDIN=$(/bin/echo "show State:/Users/ConsoleUser" | /usr/sbin/scutil | /usr/bin/awk '/Name :/&&!/loginwindow/{print $3}')
if [ "$LOGGEDIN" = "" ]; then
echo "$USER"
else
echo "$LOGGEDIN"
fi
}
SetHomeFolder() {
HOME=$(dscl . read /Users/"$1" NFSHomeDirectory | cut -d ':' -f2 | cut -d ' ' -f2)
if [ "$HOME" = "" ]; then
if [ -d "/Users/$1" ]; then
HOME="/Users/$1"
else
HOME=$(eval echo "~$1")
fi
fi
}
## Main
LoggedInUser=$(GetLoggedInUser)
SetHomeFolder "$LoggedInUser"
echo "Office-Reset: Running as: $LoggedInUser; Home Folder: $HOME"
echo "Office-Reset: Running native uninstall routine for ${APP_NAME}"
/Applications/ZoomOutlookPlugin/Uninstall/Contents/MacOS/Uninstall
echo "Office-Reset: Stopping Zoom agent"
/bin/launchctl stop /Library/LaunchAgents/us.zoom.pluginagent.plist
/bin/launchctl unload /Library/LaunchAgents/us.zoom.pluginagent.plist
/bin/launchctl stop "$HOME/Library/LaunchAgents/us.zoom.pluginagent.plist"
/bin/launchctl unload "$HOME/Library/LaunchAgents/us.zoom.pluginagent.plist"
echo "Office-Reset: Removing agent configuration for ${APP_NAME}"
/bin/rm -f /Library/LaunchAgents/us.zoom.pluginagent.plist
/bin/rm -f $HOME/Library/LaunchAgents/us.zoom.pluginagent.plist
/bin/rm -f $HOME/Library/Logs/zoomoutlookplugin.log
/bin/rm -f $HOME/Library/Preferences/ZoomChat.plist
echo "Office-Reset: Removing binaries for ${APP_NAME}"
/bin/rm -rf /Library/Application\ Support/ZoomOutlookPlugin
/bin/rm -rf /Library/Application\ Support/Microsoft/ZoomOutlookPlugin
/bin/rm -rf /Library/ScriptingAdditions/zOLPluginInjection.osax
/bin/rm -rf /Users/Shared/ZoomOutlookPlugin
/bin/rm -rf /Applications/ZoomOutlookPlugin
/usr/sbin/pkgutil --forget ZoomMacOutlookPlugin.pkg
exit 0