Installing Microsoft Office using a JumpCloud Command on macOS

Reading Time: 3 minute read.

Installing Microsoft Office using a JumpCloud Command on macOS

The second part of this series of posts regarding JumpCloud commands. Is installing Microsoft Office for Mac. This is to ease some of the pain from the onboarding process of new machines/users. I had a bit of help from a colleague (Thanks to Chris!) towards the end when writing this script but I got there in the end.

So as the previous guide you need to put the setup files somewhere accessible on a webserver. I have mine hosted on a basic Linode. You could use the links directly from MacAdmins; however, if they change the script will fail.

I set it up this command to install Word, PowerPoint and Excel individually rather than the whole Office Suite as that is all we use in my environment. However, I have added in the lines to install the entire office suite. You need to uncomment office and comment out the individual apps. You can download the different versions of each application for office from the MacAdmins website.

Now just a side note I have tested this on two different macOS Mojave test clients using the individual application Office 365 installers from MacAdmins and it worked perfectly – I take no responsibility for anything it does or does not do to your systems, however.

Below is the script with notes in the comments and you can download a zip file containing the script here. You need to modify the location of the setup files in the lines beginning curl -o  for the webserver that you have put the data on.

# Script to Download, Silent Install and then clean up once installed Microsoft Word, PowerPoint and Excel for Mac
# Writen by twitter.com/richhickson
# www.RichardHickson.com

#Make temp folder for downloads.
mkdir "/tmp/office/";
cd "/tmp/office/";

#Download Word, PowerPoint, Excel or Office (uncomment out whats not needed) into temp folder.
curl -o /tmp/office/word.pkg "http://somewebserver/word.pkg";
curl -o /tmp/office/powerpoint.pkg "http://somewebserver/powerpoint.pkg";
curl -o /tmp/office/excel.pkg "http://somewebserver/excel.pkg";
#curl -o /tmp/office/office.pkg "http://somewebserver/office.pkg";

#Silent Install each application. (uncomment out if you want the whole office suite)
sudo -S installer -allowUntrusted -pkg "/tmp/office/word.pkg" -target /;
sudo -S installer -allowUntrusted -pkg "/tmp/office/powerpoint.pkg" -target /;
sudo -S installer -allowUntrusted -pkg "/tmp/office/excel.pkg" -target /;
#sudo -S installer -allowUntrusted -pkg "/tmp/office/office.pkg" -target /;

#Define Current User
currentuser=$(ls -l /dev/console | awk '{ print $3 }')

#Add Icons to Curent Users Dock
sudo -u $currentuser defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Word.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>";
sudo -u $currentuser defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Excel.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>";
sudo -u $currentuser defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft PowerPoint.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>";

#Kill Dock
killall Dock;

#Remove Temp Files (Temp Removed)
sudo rm -rf "/tmp/office/";

If there are any other applications, you will find useful please leave me a comment below or on twitter @richhickson

Leave a Comment