mirror of
https://github.com/NohamR/Office-Reset.git
synced 2026-05-25 04:07:21 +00:00
Add Office Reset scripts and README
This commit is contained in:
62
scripts/Office_Defender_Remove.sh
Executable file
62
scripts/Office_Defender_Remove.sh
Executable 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
|
||||
Reference in New Issue
Block a user