Uninstall Office 2011 - step by step?

Not applicable

Hi all,
Im new to Casper and this whole JAMF/scripting stuiff.... but looks so cool when I read thru all your discussions.

So here is my question..
My enivorment consists of about 600 mac users.
We are planning a BIG depoloyment of office 2016 but I want to remove office 2011 first.
I would like to know how to create a script/package to remove office in its entire.... even the dock icons.
If you can, and since im a newbie - can you explain step-by-step.

I also read people taliking about this "dockuil". What is this "dockutil"?

6 REPLIES 6

sepiemoini
Contributor III
Contributor III

Greetings, @vferra and welcome to Jamf Nation!

@pbowden has a script on GitHub that'll accomplish this for you. I've successfully used this in the past to deploy across a smaller scope. I would encourage testing this a bit but you should be all set.

wesleya
Contributor

We are using a process similar to what's outlined here: https://www.jamf.com/jamf-nation/discussions/8392/removing-office-2011

Here's an overview of how we've been doing it:

Policy One:
1. Remove Office 2011 using a script in the "Scripts" payload like the one in the discussion
2. Remove 2011 icons using the "Dock Icons" payload
3. Call Policy Two with another payload in "Files and Processes": sudo jamf policy -event InstallMicrosoftOffice2016

Policy Two:
1. Activated with the custom trigger from above: InstallMicrosoftOffice2016
2. Install Office 2016 using the installer from: https://macadmins.software and a serializer from somewhere... (I don't know where, but I'll ask)
3. Add 2016 icons using another "Dock Icons" payload

I can give you some screenshots if this is unclear. Let me know.

Not applicable

@sepiemoini If I wanted to test that script on my mac before deploying - do i just need to copying it into XCODE, save it as an .sh, and run it in terminal?

Not applicable

@wesleya photos will be a big help

mark_mahabir
Valued Contributor

Have a read here for removing Office 2011.

See here for all you need to know about dockutil. There's also a good blog post here

calvins
New Contributor III

We had the same scenario as OP, here's what I came up with. We've been using this for months successfully, feel free to use.

#!/bin/bash

#General Workflow:
#1. Check if 2016 is already present, install it if not, stop if the install doesn't work so we don't leave someone without Office.
#2. Delete 2011 and some misc. preferences for each user.
#3. Move some fonts back to where Office 2011 moved them from.

#Misc: We specifically don't remove the Outlook 2011 identities or databases in case someone has a local mail profile setup.

#Requires JAMF Triggers:
    #1. "Install-Office2016" to run the Office 2016 Suite installer.
    #2. "Install-Skype" to run the Skype for Business installer.

#References:
    #http://www.officeformachelp.com/office/install/remove-office/
    #http://www.officeformachelp.com/office/install/installed-files-list-for-office-2011/
    #https://www.jamf.com/jamf-nation/discussions/18879/mac-office-2011-uninstall-script


#Function definitions
########################################################################################
install_2016()
{
    echo "Installing Office 2016 from JAMF."
    jamf policy -event Install-Office2016

    if [[ -e "/Applications/Microsoft Outlook.app" ]] && [[ -e "/Applications/Microsoft OneNote.app" ]] && [[ -e "/Applications/Microsoft Excel.app" ]] && [[ -e "/Applications/Microsoft Word.app" ]] && [[ -e "/Applications/Microsoft PowerPoint.app" ]];
        then 
            echo "Office 2016 was detected after installing from JAMF."
        else
            echo "Office 2016 was not detected after attempting to install from JAMF. The DP might not be available or the OS might not be 10.10+."
            exit 1
    fi
}

install_Skype()
{
    echo "Installing Skype for Business from JAMF"
    jamf policy -event Install-Skype
    if [ -e "/Applications/Skype for Business.app" ];
        then
            echo "Skype for Business was detected after installing from JAMF."
        else
            echo "Skype for Business was not detected after attempting to install from JAMF. Check connectivity to the DP."
            exit 1
    fi
}

remove_Office2011()
{
    echo "Stopping Office 2011 apps"
        pgrep "Microsoft Database Daemon" | xargs kill -9 2> /dev/null
        pgrep "Office365Service" | xargs kill -9 2> /dev/null
        pgrep "Microsoft AU Daemon" | xargs kill -9 2> /dev/null
        pgrep "Office365Service" | xargs kill -9 2> /dev/null
        pgrep "Communicator" | xargs kill -9 2> /dev/null
        pgrep "Microsoft Database Daemon" | xargs kill -9 2> /dev/null
        pgrep "Microsoft Lync" | xargs kill -9 2> /dev/null
        ps aux | grep "/Applications/Microsoft Office 2011" | awk '{print $2}' | xargs kill -9 2> /dev/null      #Killing the main 2011 apps (Word, PP, Excel, Outlook) by name would result in killing 2016 apps that were open at the same time since they share the exact same names, so here we kill them by file location instead.

    echo "Deleting Office 2011 folders and files"
        rm -rf '/Applications/Microsoft Communicator.app/'
        rm -rf '/Applications/Microsoft Messenger.app/'
        rm -rf '/Applications/Microsoft Lync.app/'
        rm -rf '/Applications/Microsoft Office 2011/'
        rm -rf '/Applications/Remote Desktop Connection.app/'
        rm -rf '/Library/Application Support/Microsoft/Communicator'
        rm -rf '/Library/Application Support/Microsoft/MERP2.0'
        rm -rf /Library/Automator/*Excel*
        rm -rf /Library/Automator/*Office*
        rm -rf /Library/Automator/*Outlook*
        rm -rf /Library/Automator/*PowerPoint*
        rm -rf /Library/Automator/*Word*
        rm -rf /Library/Automator/*Workbook*
        rm -rf '/Library/Automator/Get Parent Presentations of Slides.action'
        rm -rf '/Library/Automator/Set Document Settings.action'
        rm -rf /Library/Fonts/Microsoft/
        rm -rf /Library/Internet Plug-Ins/SharePoint*
        rm -rf /Library/LaunchDaemons/com.microsoft.office.licensing.helper.plist
        rm -rf /Library/PrivilegedHelperTools/com.microsoft.office.licensing.helper
}

#Put the default Mac fonts back because 2011 moves them in favor of its own.
move_fonts()
{
    echo "Move fonts back from '/Library/Fonts Disabled' to '/Library/Fonts'"
    mv '/Library/Fonts Disabled/Arial Bold Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Arial Bold.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Arial Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Arial.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Brush Script.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman Bold Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman Bold.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Times New Roman.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana Bold Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana Bold.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana Italic.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Verdana.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Wingdings 2.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Wingdings 3.ttf' /Library/Fonts
    mv '/Library/Fonts Disabled/Wingdings.ttf' /Library/Fonts
}

remove_2011Preferences()
{
    echo "Deleting global Office 2011 preferences"
        rm -rf "/Library/Preferences/com.microsoft.Word.plist"
        rm -rf "/Library/Preferences/com.microsoft.Excel.plist"
        rm -rf "/Library/Preferences/com.microsoft.Powerpoint.plist"
        rm -rf "/Library/Preferences/com.microsoft.Outlook.plist"
        rm -rf "/Library/Preferences/com.microsoft.outlook.databasedaemon.plist"
        rm -rf "/Library/Preferences/com.microsoft.DocumentConnection.plist"
        rm -rf "/Library/Preferences/com.microsoft.office.setupassistant.plist"

    # Loop through each user to kill Office 2011 Preferences and some misc folders.
    for user in $(ls /Users | grep -v Shared | grep -v npsparcc | grep -v ".localized"); #Set $user to the results of listing /Users, excluding "Shared" and "npsparcc"
    do
        echo "Cleaning $user's Office 2011 and Lync Preferences."
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.Word.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.Excel.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.Powerpoint.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.Outlook.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.outlook.databasedaemon.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.outlook.office_reminders.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.DocumentConnection.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.office.setupassistant.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.office.plist"
            rm -rf "/Users/$user/Library/Preferences/com.microsoft.error_reporting.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.Word.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.Excel.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.Powerpoint.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.Outlook.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.outlook.databasedaemon.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.DocumentConnection.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.office.setupassistant.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.registrationDB.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.e0Q*.*.plist"
            rm -rf "/Users/$user/Library/Preferences/ByHost/com.microsoft.Office365.*.plist"
            rm -rf "/Users/$user/Library/Caches/com.microsoft.browseRont.cache"
            rm -rf "/Users/$user/Library/Caches/com.microsoft.office.setupassistant"
            rm -rf "/Users/$user/Library/Caches/Microsoft/Office"
            rm -rf "/Users/$user/Library/Caches/Outlook"
            rm -rf "/Users/$user/Library/Caches/com.microsoft.Outlook"
            rm -rf "/Users/$user/Library/Application Support/Microsoft/Office"
            rm -rf /Users/$user/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.microsoft.lync.sfl
            rm -rf /Users/$user/Library/Cookies/com.microsoft.Lync.binarycookies
            rm -rf /Users/$user/Library/Caches/com.microsoft.Lync
            rm -rf /Users/$user/Library/Group Containers/UBF8T346G9.Office/Lync
            rm -rf /Users/$user/Library/Logs/Microsoft-Lync*
            rm -rf /Users/$user/Library/Preferences/ByHost/MicrosoftLync*
            rm -rf /Users/$user/Library/Preferences/com.microsoft.Lync.plist
            rm -rf /Users/$user/Library/Receipts/Lync.Client.Plugin.plist
            rm -rf /Users/$user/Library/Keychains/OC_KeyContainer*
            rm -rf /Users/$user/Documents/Microsoft User Data/Microsoft Lync Data 
            rm -rf /Users/$user/Documents/Microsoft User Data/Microsoft/Communicator
    done
}

remove_2011DockIcons()
{
    #Each ID corresponds to a dock icon in the JSS. Here we leave the dock running until the last icon to avoid a bunch of dock re-launches.
    #Adding a pause between each removal makes the actual removal of the icons more reliable. If you run them back to back with no pausing, it frequently just doesn't do a couple at random.
    echo "Removing Office 2011 and Lync 2011 Dock Icons from all docks..."
    jamf modifyDock -id 28 -remove -leaveRunning    #Microsoft Word 2011
    sleep 1
    jamf modifyDock -id 29 -remove -leaveRunning    #Microsoft PowerPoint 2011
    sleep 1
    jamf modifyDock -id 30 -remove -leaveRunning    #Microsoft Lync 2011
    sleep 1
    jamf modifyDock -id 31 -remove -leaveRunning    #Microsoft Outlook 2011
    sleep 1
    jamf modifyDock -id 52 -remove -leaveRunning    #Equation Editor
    sleep 1
    jamf modifyDock -id 33 -remove -leaveRunning    #Microsoft Database Utility
    sleep 1
    jamf modifyDock -id 34 -remove -leaveRunning    #Microsoft Graph
    sleep 1
    jamf modifyDock -id 35 -remove -leaveRunning    #Microsoft Query
    sleep 1
    jamf modifyDock -id 36 -remove -leaveRunning    #Microsoft Upload Center
    sleep 1
    jamf modifyDock -id 42 -remove -leaveRunning    #Microsoft Communicator
    sleep 1
    jamf modifyDock -id 43 -remove -leaveRunning    #Microsoft Document Connection  
    sleep 1
    jamf modifyDock -id 50 -remove -leaveRunning    #Solver         
    sleep 1
    jamf modifyDock -id 51 -remove -leaveRunning    #My Day 
    sleep 1
    jamf modifyDock -id 46 -remove                  #Microsoft Excel 2011               
}

#Just some housekeeping.
remove_Office2011Receipts()
{
    #Kill the package receipts for Office.
    echo "Removing all Office package receipts"
    OFFICERECEIPTS=$(pkgutil --pkgs=com.microsoft.office.*)
    for RECEIPT in $OFFICERECEIPTS
    do
        pkgutil --forget $RECEIPT
    done
}


########################################################################################
#Install Office 2016 and exit if the install doesn't work. Don't want to leave someone without Office.
if [[ -e "/Applications/Microsoft Outlook.app" ]] && [[ -e "/Applications/Microsoft OneNote.app" ]] && [[ -e "/Applications/Microsoft Excel.app" ]] && [[ -e "/Applications/Microsoft Word.app" ]] && [[ -e "/Applications/Microsoft PowerPoint.app" ]];
    then
        echo "The entire Office 2016 suite was detected."
    else
        echo "Office 2016 was not detected."
        install_2016
fi

if [ -e "/Applications/Skype for Business.app" ];
    then
        echo "Skype for Business was detected."
    else
        echo "Skype for Business not found, installing."
        install_Skype
fi

#If you get this far, you have all of 2016 + Skype, so the 2011 uninstall starts.
remove_Office2011
move_fonts
remove_2011Preferences
remove_2011DockIcons
remove_Office2011Receipts