Skip to main content
Jamf Nation, hosted by Jamf, is a knowledgeable community of Apple-focused admins and Jamf users. Join us in person at the ninth annual Jamf Nation User Conference (JNUC) this November for three days of learning, laughter and IT love.

Office 2016 removal script

We've found this script extremely useful for removing Office 2011.

Is there something similar floating around for Office 2016?

Like Comment
Order by:
SOLVED Posted: by donmontalvo

Sandboxed, just remove the apps, no?

Like
SOLVED Posted: by stuartwilcox

This is what we use and it works really well. There is a section towards the bottom that you should comment out if you plan to preserve Outlook data.

#!/bin/bash


consoleuser=$(ls -l /dev/console | awk '{ print $3 }')

echo "logged in user is" $consoleuser

pkill -f Microsoft


folders=(
"/Applications/Microsoft Excel.app"
"/Applications/Microsoft OneNote.app"
"/Applications/Microsoft Outlook.app"
"/Applications/Microsoft PowerPoint.app"
"/Applications/Microsoft Word.app"
#
"/Users/$consoleuser/Library/Containers/com.microsoft.errorreporting"
"/Users/$consoleuser/Library/Containers/com.microsoft.Excel"
"/Users/$consoleuser/Library/Containers/com.microsoft.netlib.shipassertprocess"
"/Users/$consoleuser/Library/Containers/com.microsoft.Office365ServiceV2"
"/Users/$consoleuser/Library/Containers/com.microsoft.Outlook"
"/Users/$consoleuser/Library/Containers/com.microsoft.Powerpoint"
"/Users/$consoleuser/Library/Containers/com.microsoft.RMS-XPCService"
"/Users/$consoleuser/Library/Containers/com.microsoft.Word"
"/Users/$consoleuser/Library/Containers/com.microsoft.onenote.mac"
#
#
#### WARNING: Outlook data will be removed when you move the three folders listed below.
#### You should back up these folders before you delete them.
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.ms"
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.Office"
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.OfficeOsfWebHost"
)

search="*"


for i in "${folders[@]}"
do
    echo "removing folder ${i}"
    rm -rf "${i}"
done

if [ $? == 0 ]; then
     echo "Success"
else
     echo "Failure"
fi
Like
SOLVED Posted: by ianmb

This is perfect, thanks!

Like
SOLVED Posted: by Mikep62

Bl*Y fantastic!! whatever you do don't install the 16.17 updater on the M/soft Office 2016 site. It breaks all the VL licensing WTH! The only way is to tear down the installation(there is no Msoft uninstaller to make things worse) which this script does perfectly via ARD (as root) Reinstall the 16.16.2 from the VL site and reinstall the serializer and all is good again. Not funny when you have over 350 broken MS Office macs!
Beware this 16.17update!!!! https://docs.microsoft.com/en-us/officeupdates/update-history-office-for-mac

Great work and my bacon has been saved by this script, I totally recommend it and is now pride of place in my ARD templates!! Thanks stuartwilcox

Like
SOLVED Posted: by TomDay

@Mikep62 Think I got bit by this 16.17 issue too, getting lots of complaints about Office copies suddenly needing to be activated! Have you seen this documented anywhere, please share?

This uninstall script has been very helpful today, TY @stuartwilcox

Like
SOLVED Posted: by cnorrisAdmin

But if you have a VL you should also get the Microsoft_Office_2016_VL_Serializer_2.0.pkg along with the installer files. Installing the Microsoft_Office_2016_VL_Serializer_2.0.pkg should fix the VL licensing.

Like
SOLVED Posted: by sbirdsley

@TomDay Got caught on this as well for any systems we didn't update through MAU

MacAdmins has it very clear on the difference between 16.16.2 and 16.7

Unlike the MS Update history page that didn't make this very clear

Not sure on your environment or if have looked at this yet but would highly recommend leveraging MAU. We are using this script currently for our Office 2016 updates that has eliminated me having to distribute to the majority of our systems the full office installer package

Like
SOLVED Posted: by TomDay

@sbirdsley Will give a look, right now I push out with patch management

Like
SOLVED Posted: by supson

Doesn't the Office 365 Installer require some authentication through your Office 365 account to license it?

Like
SOLVED Posted: by Jackfh1

Is there a way to remove any MS Office dock items? i see this script leaves them in place.

Like
SOLVED Posted: by ryan.ball

@Jackfh1 I did not test this but this might work. You'd need dockutil.

#!/bin/bash

userList=$(/usr/bin/dscl . list /Users | grep -v ^_ | grep -v daemon | grep -v r00t | grep -v root | grep -v nobody)

officeApps=(
    Word
    Excel
    Outlook
    PowerPoint
)

for userName in ${userList} ; do
    echo "Removing Office Dock items for $userName..."
    userHome=$(/usr/bin/dscl . read "/Users/$userName" NFSHomeDirectory | awk '{print $2}')
    for app in "${officeApps[@]}" ; do
        /usr/local/bin/dockutil --remove "Microsoft $app" --no-restart "$userHome/Library/Preferences/com.apple.dock.plist"
    done
done

pgrep Dock 2&> /dev/null && killall Dock

exit 0
Like
SOLVED Posted: by pete_c

Slightly tweaked to include Microsoft OneNote and OneDrive which does not include Microsoft in its Dock item label - probably a slightly cleaner / bash-ier way, but this works on 10.13+:

#!/bin/bash

userList=$(/usr/bin/dscl . list /Users | grep -v ^_ | grep -v daemon | grep -v r00t | grep -v root | grep -v nobody | grep -v Guest)

officeApps=(
    "Microsoft Word"
    "Microsoft Excel"
    "Microsoft Outlook"
    "Microsoft OneNote"
    "OneDrive"
    "Microsoft PowerPoint"
)

for userName in ${userList} ; do
    echo "Removing Office Dock items for $userName..."
    userHome=$(/usr/bin/dscl . read "/Users/$userName" NFSHomeDirectory | awk '{print $2}')
    for app in "${officeApps[@]}" ; do
        /usr/local/bin/dockutil --remove "$app" --no-restart "$userHome/Library/Preferences/com.apple.dock.plist"
    done
done

pgrep Dock 2&> /dev/null && killall Dock

exit 0
Like
SOLVED Posted: by rfreeborn

Thanks @stuartwilcox I added some other files to the script to completely remove all files present from Install of latest version or Office 2019. ( See below) Tested on High Sierra and Mojave. Also works on Office 2016 previous installs. I have also found that this works great as script in my Office 2019 Install Policy set to run "Before" Install and a Script to remove First Run Setup processes. This way if a user goes to MacApp Store and installs the Office 365 from there. This was causing issues when they then ran our Volume License install with Volume Serializer where Office would only open in trial or read only mode if user selected in the setup for the MacApp Store version. By adding this script it clears all parts of previous installs and then installs our Volume License version downloaded from https://macadmins.software and installs our Volume Serializer package. I then use the Dock Items to add icons to dock. If their were any items in dock from previous installs, they are over-written with the new ones.

#!/bin/bash


consoleuser=$(ls -l /dev/console | awk '{ print $3 }')

echo "logged in user is" $consoleuser

pkill -f Microsoft


folders=(
"/Applications/Microsoft Excel.app"
"/Applications/Microsoft OneNote.app"
"/Applications/Microsoft Outlook.app"
"/Applications/Microsoft PowerPoint.app"
"/Applications/Microsoft Word.app"
"/Library/Application\ Support/Microsoft/"
#
"/Users/$consoleuser/Library/Application\ Support/Microsoft AU Daemon"
"/Users/$consoleuser/Library/Application Support/Microsoft AutoUpdate"
"/Users/$consoleuser/Library/Preferences/com.microsoft.autoupdate.fba.debuglogging.plist"
"/Users/$consoleuser/Library/Preferences/com.microsoft.autoupdate.fba.plist"
"/Users/$consoleuser/Library/Preferences/com.microsoft.autoupdate2.plist"
"/Users/$consoleuser/Library/Containers/com.microsoft.errorreporting"
"/Users/$consoleuser/Library/Containers/com.microsoft.Excel"
"/Users/$consoleuser/Library/Containers/com.microsoft.netlib.shipassertprocess"
"/Users/$consoleuser/Library/Containers/com.microsoft.Office365ServiceV2"
"/Users/$consoleuser/Library/Containers/com.microsoft.Outlook"
"/Users/$consoleuser/Library/Containers/com.microsoft.Powerpoint"
"/Users/$consoleuser/Library/Containers/com.microsoft.RMS-XPCService"
"/Users/$consoleuser/Library/Containers/com.microsoft.Word"
"/Users/$consoleuser/Library/Containers/com.microsoft.onenote.mac"
#
#
#### WARNING: Outlook data will be removed when you move the three folders listed below.
#### You should back up these folders before you delete them.
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.ms"
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.Office"
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.OfficeOsfWebHost"
"/Users/$consoleuser/Library/Group Containers/UBF8T346G9.OfficeOneDriveSyncIntegration"
)

search="*"


for i in "${folders[@]}"
do
    echo "removing folder ${i}"
    rm -rf "${i}"
done
Like