Posted on 07-19-2016 01:37 AM
We've found this script extremely useful for removing Office 2011.
Is there something similar floating around for Office 2016?
Solved! Go to Solution.
Posted on 07-19-2016 08:26 AM
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
Posted on 07-19-2016 07:29 AM
Sandboxed, just remove the apps, no?
Posted on 07-19-2016 08:26 AM
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
Posted on 07-21-2016 07:08 AM
This is perfect, thanks!
Posted on 09-18-2018 01:48 AM
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
Posted on 09-18-2018 10:39 AM
@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
Posted on 09-18-2018 11:38 AM
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.
Posted on 09-18-2018 11:48 AM
@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
Posted on 09-18-2018 12:28 PM
@sbirdsley Will give a look, right now I push out with patch management
Posted on 10-04-2018 01:43 PM
Doesn't the Office 365 Installer require some authentication through your Office 365 account to license it?
Posted on 04-04-2019 11:06 AM
Is there a way to remove any MS Office dock items? i see this script leaves them in place.
Posted on 04-04-2019 11:18 AM
@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
Posted on 07-30-2019 02:21 PM
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
Posted on 08-20-2019 11:27 AM
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
Posted on 02-16-2020 10:18 PM
Can anyone please help me understand what search="*" does?
Posted on 06-19-2020 10:03 AM
new here, I just receive this message when I try to run it via script editor - 'Apple events error: "Expected expression but found unknown token'
Posted on 06-19-2020 10:24 AM
@igarcia These scripts aren't AppleScript, so you can't use Script Editor to work with them.
Posted on 07-15-2020 12:01 PM
@rfreeborn hey does your script remove Office 2016 and 2019, whatever version is installed on the target computer?
also , basically all the macs here don't have 'onenote' 'mau' and 'outlook' installed so will i have to comment out any lines that mention 'onenote' 'mau' and 'outlook'? or will the script run and just not rm -rf the particular file/folder when it reaches that folder in the do loop? or will it jump out of the do loop if the folder is not there to rm -rf ?? thus not completing the uninstall.
maybe a dozen have onenote installed while the other 160 don't have onenote installed. All macs have Excel, PPoint and Word installed. We control the Office updates with policies that install the updates on user logout, so MAU is not installed on basically all macs as well.
Posted on 10-07-2020 09:20 AM
Thanks for the help with this Jamfs!
Posted on 10-07-2020 12:47 PM
Check out the tools available at https://office-reset.com/macadmins/ for removing Office.
Posted on 10-07-2020 05:38 PM
And I’m more than happy to answer any questions you have about Office-Reset :)
Posted on 10-07-2020 07:17 PM
@pbowden what does the complete removal.pkg do actually do, does it remove either office 2016 or 2019 whichever is installed? I only install Excel, Word, Powerpoint using a applychoicechanges.xml file in my Office 2016/2019 installation pkg policy.
this is what the site says
Complete Removal goes one step further by also removing apps, launch agents/daemons, and MAU. It is designed for scenarios where you want to completely remove every trace of Office from a Mac, such as a lab computer where you're performing version and UI behavior testing.
Posted on 10-07-2020 08:36 PM
Hi @tcandela that’s correct. The complete removal package removes all traces of Office 2016, 2019 and 365. It will auto-detect which versions and builds you have installed.
Let me know what your scenario is (ie what are you trying to achieve) and I can advise on your best option.
Thanks! Paul.
Posted on 10-08-2020 06:28 AM
@pbowden im just trying to use it just for uninstall purposes. Im currently using the same script for both 2016 and 2019, but this pkg seems it is more thorough.
Then if necessary would reinstall using my policy.
Upgrade from office 2016 to 2019
Posted on 10-08-2020 06:37 AM
@tcandela yup, the complete removal package is great for uninstall scenarios.
FYI - you don’t need to uninstall 2016 before installing 2019. You can simply install 2019 right over the top of 2016.
Posted on 10-08-2020 11:13 AM
@pbowden if you do the 2019 install over the top of 2016, what happens when the 2019 serializer installs?
Posted on 10-08-2020 11:16 AM
@tcandela the 2019 VL Serializer will delete any existing VL plist (in /Library/Preferences) and then create a new license that’s compatible with 2019.
Posted on 10-10-2020 09:39 AM
@pbowden I'm about to run the complete_removal.pkg on a Mac running office 2019 (word, excel, powerpoint are installed, no other office applications), will I be seeing any sort of prompts? or will it just remove office 2019 stuff?
looks to me the the 'reset' pkgs, based on reading the faqs will prompt users to select options???
Posted on 10-10-2020 11:13 AM
@tcandela if you run the complete removal package via the Jamf agent or self service that user won’t see any prompts.
The only case where the user will see prompts and options is if you launch the pkg manually in the GUI.
Posted on 10-11-2020 06:49 PM
@pbowden Thank you for the work you did on those scripts. Very, very helpful!
Posted on 10-11-2020 08:12 PM
@dlondon you’re welcome! Thanks for the compliment!
Posted on 11-19-2020 06:11 AM
@pbowden I haven't tested this out yet, however, I'm excited to try. I noticed there is a "Skype for Business Removal Package" in there, which, will be handy since we have moved to Teams.
Posted on 11-19-2020 12:29 PM
@bcbackes great! Let me know if you have any questions when you test this out.
Posted on 03-03-2021 10:58 AM
@pbowden I'm sorry it took so long to reply back on this. I'm running all of this "awesomeness" through our QA Lab and I have a couple things that I noticed during testing. I'm not sure if this is expected or not, please, let me know.
OneDrive Reset - Running the reset doesn't delete the one drive folder on users Mac
Teams Reset - it keeps my profile which i can choose to login even after reset
If you say that's expected behavior with the reset for OneDrive and Teams, I'll take it and run and assume I'll need to use the removal to complete remove the Teams profile and OneDrive folder. Thoughts?