Skip to main content

Office for mac removal script.



#!/bin/sh
## postflight
## Office for mac removal script by tausif


###############################################################################
# Set variables #
###############################################################################
HOME=$(sudo dscl . -read /Users/$USERNAME NFSHomeDirectory | awk '{print $2}')
#get actual home directory on mac
person=$( ls -l /dev/console | awk '{print $3}' )
#get logged in user
sudo touch "/private/var/log/office_install.log"
logFile="/private/var/log/office_install.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}

if ! (which -s dockutil && dockutil --version | grep -q '^1.1.4$';); then
cd /usr/sbin
sudo curl -O https://raw.githubusercontent.com/kcrawford/dockutil/ef55cb4cf94659074d4a4ea915e76fefbf322545/scripts/dockutil
#check for dockutil v 1.1.4 and if not there download it

sudo chmod +x /usr/sbin/dockutil
fi

###############################################################################
# Remove Dock items early #
###############################################################################
/usr/sbin/dockutil --remove 'Microsoft Word' --allhomes
/usr/sbin/dockutil --remove 'Microsoft Excel' --allhomes
/usr/sbin/dockutil --remove 'Microsoft Outlook' --allhomes
/usr/sbin/dockutil --remove 'Microsoft PowerPoint' --allhomes
/usr/sbin/dockutil --remove 'Microsoft Document Connection' --allhomes

log "removed from dock"
# Install receipts assingment
OFFICERECEIPTS=$(pkgutil --pkgs=com.microsoft.office*)
osascript -e 'tell application "Microsoft Database Daemon" to quit'
log "Kill Microsoft Database Daemon"

sudo rm -rf '/Applications/Microsoft Communicator.app/'
sudo rm -rf '/Applications/Microsoft Messenger.app/'
sudo rm -rf '/Applications/Microsoft Office 2011/'
sudo rm -rf '/Applications/Remote Desktop Connection.app/'
log "Remove apps"

sudo rm -rf '/Library/Application Support/Microsoft/'
sudo rm -rf '/Library/Automator/*Excel*'
sudo rm -rf '/Library/Automator/*Office*'
sudo rm -rf '/Library/Automator/*Outlook*'
sudo rm -rf '/Library/Automator/*PowerPoint*'
sudo rm -rf '/Library/Automator/*Word*'
sudo rm -rf '/Library/Automator/Add New Sheet to Workbooks.action'
sudo rm -rf '/Library/Automator/Create List from Data in Workbook.action'
sudo rm -rf '/Library/Automator/Create Table from Data in Workbook.action'
sudo rm -rf '/Library/Automator/Get Parent Presentations of Slides.action'
sudo rm -rf '/Library/Automator/Get Parent Workbooks.action'
sudo rm -rf '/Library/Automator/Set Document Settings.action'
sudo rm -rf '/Library/Fonts/Microsoft/'
sudo rm -rf '/Library/Internet Plug-Ins/*SharePoint*'
sudo rm -rf '/Library/LaunchDaemons/*Microsoft*'
sudo rm -rf '/Library/Preferences/*Microsoft*'
sudo rm -rf '/Library/PrivilegedHelperTools/*Microsoft*'
sudo rm -rf '$HOME/Library/Application Support/Microsoft/'
sudo rm -rf '$HOME/Library/Preferences/com.microsoft.*'

log "remove library items"

# Forget Install Receipts

for ARECEIPT in $OFFICERECEIPTS
do
pkgutil --forget $ARECEIPT
done

log "forgot receipts"
killall Dock
echo "All done, MS Office removed."
exit 0

Comments

Popular posts from this blog

Removing corporate wireless restrictions completely : "The policies of your network prevent the creation of ad hoc (computer-to-computer) networks. For more information, contact your system administrator."

So i was recently tasked with removing wireless restrictions from a VP's windows 7 laptop that some infrastructure company had placed while contracted with our network, since he needed to enable setting up of adhoc connections on his laptop and he always got

"The policies of your network prevent the creation of ad hoc (computer-to-computer) networks. For more information, contact your system administrator."


A little bit of probing revealed that adhoc and peer to peer connections were blocked as evidenced by the the command 

netsh wlan show filter on an  elevated command prompt revealed that adhoc network type was blocked by group policy:

I removed the restrictions by:

1: open services.msc as administrator, scroll down to WLAN AutoConfig:

To Unlock Windows Update locked due to group policy.

To Unlock Windows Update locked due to group policy.




Open gpedit.msc and browse to the location /Computer Configuration/Administrative Templates/System/Internet Communication Management/Internet Communication Settings and double click "turn off access to all windows update features" and set it to disabled.

Migrating Outlook Profile to Office 365

We had a migration from Hosted Exchange to Office 365 and i was tasked with automating the local Outloook profile migration for Users:

I Created a GUI utility using powershell which would allow users to create an Office365 Profile and set it as default, I prepared PRF files for each version of office and an autodiscover.xml to be used for local autodiscover and uploaded them to a hosted site:

The PRF file to set settings for Office 365 are hard to find: i used the below entries:


;AutomaticallygeneratedPRFfilefromtheMicrosoftOfficeCustomizationandInstallationWizard;**************************************************************;Section1-ProfileDefaults;**************************************************************[General]Custom=1ProfileName=%UserName%-O365DefaultProfile=YesOverwriteProfile=YesModifyDefaultProfileIfPresent=false;**************************************************************;Section2-ServicesinProfile;**************************************************************[Service…