#!/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