Posted on 12-20-2021 12:21 PM
I'm trying to remove all Office 365 applications and any file with the word Microsoft in it from all our Macs. I wrote a .sh script and it is installed with Composer. Then a I have a script run that is sudo sh /path to .sh command. The Composer package will remove all the applications after a while but most of the rest of the files aren't removed. If I copy one line and paste it into Terminal it will run and remove the file(s). Why will the Terminal commands work in Terminal but not when I run them in Composer. My .sh script is setup like this but with a lot more paths listed: Thanks!
sudo rm -R /Applications/Microsoft\ Excel.app;
sudo rm -R /Applications/Microsoft\ OneNote.app;
sudo rm -R /Applications/OneDrive.app;
sudo rm -R /Applications/Microsoft\ Outlook.app;
sudo rm -R /Applications/Microsoft\ PowerPoint.app;
sudo rm -R /Applications/Microsoft\ Word.app;
sudo rm -R /Applications/Microsoft\ Teams.app;
sudo rm -R /Applications/Microsoft\ To Do;
sudo rm -R /Applications/Office.app;
sudo rm -R /Applications/Microsoft\ OneDrive.app;
sudo rm -R /Applications/'Outlook*’;
sudo rm -R /Applications/Microsoft*;
sudo rm -R /Users/*/Library/Containers/com.microsoft*;
sudo rm -R /Users/*/Library/Containers/'OneDrive File Provider';
sudo rm -R /Users/*/Library/Containers/Microsoft*;
Posted on 12-20-2021 12:51 PM
Hi Macgeek, I would not use composer to package a script. Jamf has a script section so use Jamf to handle it since it runs as root anyways. Here is my MS Office uninstaller script:
#!/bin/bash
consoleuser=$(ls -l /dev/console | awk '{ print $3 }')
echo "logged in user is" $consoleuser
echo "Kill Microsoft Office Process..."
pkill -f Microsoft
folders=(
"/Applications/Microsoft Excel.app"
"/Applications/Microsoft OneNote.app"
"/Applications/Microsoft Outlook.app"
"/Applications/Microsoft PowerPoint.app"
"/Applications/Microsoft Word.app"
"/Applications/Microsoft Teams.app"
"/Applications/OneDrive.app"
"/Library/Application Support/Microsoft"
#
"/Users/$consoleuser/Library/Application\ Support/Microsoft AU Daemon"
"/Users/$consoleuser/Library/Application\ Support/Microsoft AutoUpdate"
"/Users/$consoleuser/Library/Application\ Support/com.microsoft.OneDriveStandaloneUpdater/"
"/Users/$consoleuser/Library/Application\ Support/Microsoft\ Update\ Assistant/"
"/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/Preferences/com.microsoft.office.plist"
"/Users/$consoleuser/Library/Preferences/com.microsoft.OneDriveStandaloneUpdater.plist"
"/Users/$consoleuser/Library/Preferences/com.microsoft.OneDriveUpdater.plist"
"/Users/$consoleuser/Library/Preferences/com.microsoft.shared.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 12-20-2021 12:55 PM
I'm confused as to why you are using composer to install a script? Any script can run direct from within a policy. I use this one, to remove Office files. It does not remove Teams, I've not ammened it, but other than that it does a good job. The creators name is in the script.
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "
ROOT PRIVILEDGES NEEDED!
You have to run this script as root.
Aborting...
"
exit 1
else
echo -e "
###################################
Office 2016 for Mac uninstaller
###################################
Unofficial unistaller
Brought to you by Frank Pira
(fpira.com)
This software comes with absolutely
NO WARRANTY
Use it at your own risk.
"
sleep 4
echo -e "
------------- WARNING -------------
Your Outlook data will be wiped.
Press CTRL+C in 5 seconds to ABORT
or just sit back and relax!
-----------------------------------
"
sleep 6
# commands out of the official guide from microsoft
# source https://support.office.com/en-us/article/Uninstall-Office-2016-for-Mac-eefa1199-5b58-43af-8a3d-b73dc...
echo " Removing Office 2016 apps..."
rm -rf "/Applications/Microsoft Excel.app"
rm -rf "/Applications/Microsoft OneNote.app"
rm -rf "/Applications/Microsoft Outlook.app"
rm -rf "/Applications/Microsoft PowerPoint.app"
rm -rf "/Applications/Microsoft Word.app"
echo " Cleaning ~/Library..."
rm /Users/$(whoami)/Library/Containers/com.microsoft.errorreporting
rm /Users/$(whoami)/Library/Containers/com.microsoft.Excel
rm /Users/$(whoami)/Library/Containers/com.microsoft.netlib.shipassertprocess
rm /Users/$(whoami)/Library/Containers/com.microsoft.Office365ServiceV2
rm /Users/$(whoami)/Library/Containers/com.microsoft.Outlook
rm /Users/$(whoami)/Library/Containers/com.microsoft.Powerpoint
rm /Users/$(whoami)/Library/Containers/com.microsoft.RMS-XPCService
rm /Users/$(whoami)/Library/Containers/com.microsoft.Word
rm /Users/$(whoami)/Library/Containers/com.microsoft.onenote.mac
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.ms"
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.Office"
rm "/Users/$(whoami)/Library/Group ContainersUBF8T346G9.OfficeOsfWebHost"
# further cleaning
echo " Cleaning system folders..."
rm -rf "/Library/Application Support/Microsoft/MAU2.0"
rm -rf "/Library/Fonts/Microsoft"
rm /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist
rm /Library/LaunchDaemons/com.microsoft.office.licensingV2.helper.plist
rm /Library/Preferences/com.microsoft.Excel.plist
rm /Library/Preferences/com.microsoft.office.plist
rm /Library/Preferences/com.microsoft.office.setupassistant.plist
rm /Library/Preferences/com.microsoft.outlook.databasedaemon.plist
rm /Library/Preferences/com.microsoft.outlook.office_reminders.plist
rm /Library/Preferences/com.microsoft.Outlook.plist
rm /Library/Preferences/com.microsoft.PowerPoint.plist
rm /Library/Preferences/com.microsoft.Word.plist
rm /Library/Preferences/com.microsoft.office.licensingV2.plist
rm /Library/Preferences/com.microsoft.autoupdate2.plist
rm -rf /Library/Preferences/ByHost/com.microsoft
rm -rf /Library/Receipts/Office2016_*
rm /Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper
rm /Library/PrivilegedHelperTools/com.microsoft.office.licensingV2.helper
echo " Making your Mac forget about Office 2016..."
pkgutil --forget com.microsoft.package.Fonts
pkgutil --forget com.microsoft.package.Microsoft_AutoUpdate.app
pkgutil --forget com.microsoft.package.Microsoft_Excel.app
pkgutil --forget com.microsoft.package.Microsoft_OneNote.app
pkgutil --forget com.microsoft.package.Microsoft_Outlook.app
pkgutil --forget com.microsoft.package.Microsoft_PowerPoint.app
pkgutil --forget com.microsoft.package.Microsoft_Word.app
pkgutil --forget com.microsoft.package.Proofing_Tools
pkgutil --forget com.microsoft.package.licensing
echo -e "
All done!
You may need to reinstall Microsoft Silverlight.
You can now remove icons from Dock (if any!).
"
fi
Posted on 12-20-2021 02:39 PM
Take a look at this webpage:
https://office-reset.com/macadmins/
There is a package for a complete removal of Office. This site is run by Paul Bowden from Microsoft. His tools are top notch.
Posted on 01-04-2022 07:53 AM
Thanks Tribruin,
The removal script on that website does a good job and is very fast. However, it still doesn't completely remove/change all of Microsoft Office. When I install our regualar version of MS Office and Word is launched you see places that allow you to sign in. If you try to sign in you only get a blank page.
When I install Office 365 and login to register my ID I don't get the same results. I remove Office 365, reinstall our regular version with our serial number and at first launch I'm presented with a sign in button. If I try to sign in I am able to.
In Windows we are allowed to change that correctly so the user cannot log in after 365 is removed and our version with the serial number is installed. It appears that can only be done correctly using Windows.
Posted on 07-18-2024 04:34 AM
I tried this using the instrustions for Jamf Pro but it didn't work. seemed straight forward. I set it for the login trigger but no dice.
Posted on 12-21-2021 02:17 AM
Refer to this official article provided by Microsoft Office: https://support.microsoft.com/en-us/office/uninstall-office-from-a-pc-9dd49b83-264a-477a-8fcc-2fdf5d...
Posted on 12-27-2021 06:13 AM
Echoing what @Tribruin says - the Office Reset packages work great.