MS AutoUpdate at build time using msupdate?

PhillyPhoto
Valued Contributor

I'm looking to run msupdate in my build script so I always have the latest Office products on devices before users get the device. I've noticed in the past that even running the GUI, it doesn't actually update any apps until you've been using them for a while. 

Has anyone had luck using MAU (msupdate in particular) prior to the first run?

4 REPLIES 4

AJPinto
Honored Contributor III

That is not really how the tool works. You configure MAU with a Configuration Profile and can adjust how frequently it checks for updates and what kind of deferral it provides before running updates. I think there is also an app registration process that must happen.

 

If you are in an environment that requires the most recent version to be on a device before deployment, I suggest either:

  • maintaining the policies and updating them as needed yourself
  • Looking into Jamfs Mac Apps.
  • Use the AppStore. I don't usually suggest the Appstore, but it will always install the current version and manages patching.
  • If you wanted to get overly fancy you could also CURL, the office packages down and run them with a script. I recommend against doing it this way.

PhillyPhoto
Valued Contributor

I don't need the absolutely latest since most of our users are on a 28 day deferred schedule, but not having to download and upload PKGs every month would be nice. Mac Apps install timing is too erratic as to when apps get installed for build-time verification, and the AppStore I don't believe wouldn't respect the 28 day deferral. I'm doing your first recommendation now but don't often have enough cycles to keep the M365 pkg updated.

cbrewer
Valued Contributor II

Start installing Microsoft Office with a script that downloads the package direct from Microsoft and installs it. Then you're always installing the latest version. You could probably use installomater for that or build your own.

Basically, curl "https://go.microsoft.com/fwlink/?linkid=525133" and then use "installer -pkg" to install. Add checks and a cleanup process to get fancy.

easyedc
Valued Contributor II

Passing along a script I found somewhere along the way. #payitforward

#!/bin/bash
#####################################################################################################
#
# Script To let you pick with appliction or suite to download.  Microsoft URL's are static, will always pull latest version.
#
#####################################################################################################
# Microsoft Office Suite  - Download and Install Latest.sh
# -- Modified from Script originally published at https://gist.github.com/opragel/bda5626c3b13c3fe5467
# -- * TEST TEST TEST!! * -- No one is claiming this to be a "production ready" script... test and tweak to your needs!
# Comment any download url below to skip install #
DOWNLOAD_URLS=( \
	# Complete Office 365
	#"https://go.microsoft.com/fwlink/?linkid=525133" \
    # Complete Office 365 BusinessPro Suite
	"https://go.microsoft.com/fwlink/?linkid=2009112" \
	# Complete Office 2016
	#"https://go.microsoft.com/fwlink/?linkid=871743" \
	# Word 365
	#"https://go.microsoft.com/fwlink/?linkid=525134" \
	# Word 2016
	#"https://go.microsoft.com/fwlink/?linkid=871748" \
	# Excel 365
	#"https://go.microsoft.com/fwlink/?linkid=525135" \
	# Excel 2016
	#"https://go.microsoft.com/fwlink/?linkid=871750" \
	# Powerpoint 365
	#"https://go.microsoft.com/fwlink/?linkid=525136" \
	# Powerpoint 2016
	#"https://go.microsoft.com/fwlink/?linkid=871751" \
	# Outlook 365
	#"https://go.microsoft.com/fwlink/?linkid=525137" \
	# Outlook 2016
	#"https://go.microsoft.com/fwlink/?linkid=871753" \
	# OneNote 365
	#"https://go.microsoft.com/fwlink/?linkid=820886" \
	# OneDrive
	#"https://go.microsoft.com/fwlink/?linkid=823060" \
	# Skype for Business
	#"https://go.microsoft.com/fwlink/?linkid=832978" \
	# Teams
	#"https://go.microsoft.com/fwlink/?linkid=869428" \
	# Intune Company Portal
	#"https://go.microsoft.com/fwlink/?linkid=869655" \
	# Remote Desktop
	# "https://go.microsoft.com/fwlink/?linkid=868963" \
	# Microsoft AutoUpdate (MAU)
	"https://go.microsoft.com/fwlink/?linkid=830196" \
	)
MAU_PATH="/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app"
SECOND_MAU_PATH="/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app/Contents/MacOS/Microsoft AU Daemon.app"
INSTALLER_TARGET="LocalSystem"
/usr/bin/syslog -s -l error "MSOFFICE365 - Starting Download/Install sequence."
for downloadUrl in "${DOWNLOAD_URLS[@]}"; do
	finalDownloadUrl=$(curl "$downloadUrl" -s -L -I -o /dev/null -w '%{url_effective}')
	pkgName=$(printf "%s" "${finalDownloadUrl[@]}" | sed 's@.*/@@')
	pkgPath="/tmp/$pkgName"
	/usr/bin/syslog -s -l error "MSOFFICE365 - Downloading %s\n" "$pkgName"
	# modified to attempt restartable downloads and prevent curl output to stderr
	until curl --retry 1 --retry-max-time 180 --max-time 180 --fail --silent -L -C - "$finalDownloadUrl" -o "$pkgPath"; do
		# Retries if the download takes more than 3 minutes and/or times out/fails
		/usr/bin/syslog -s -l error "MSOFFICE365 - Preparing to re-try failed download: %s\n" "$pkgName"
		/bin/sleep 10
	done
	/usr/bin/syslog -s -l error "MSOFFICE365 - Installing %s\n" "$pkgName"
	# run installer with stderr redirected to dev null
	installerExitCode=1
	while [ "$installerExitCode" -ne 0 ]; do
		sudo /usr/sbin/installer -pkg "$pkgPath" -target "$INSTALLER_TARGET" > /dev/null 2>&1
		installerExitCode=$?
		if [ "$installerExitCode" -ne 0 ]; then
		/usr/bin/syslog -s -l error "MSOFFICE365 - Failed to install: %s\n" "$pkgPath"
		/usr/bin/syslog -s -l error "MSOFFICE365 - Installer exit code: %s\n" "$installerExitCode"
		fi
	done
	/bin/rm -rf "$pkgPath"
done
# -- Modified from Script originally published at https://gist.github.com/erikng/7cede5be1c0ae2f85435
/usr/bin/syslog -s -l error "MSOFFICE365 - Registering Microsoft Auto Update (MAU)"
if [ -e "$MAU_PATH" ]; then
	/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -R -f -trusted "$MAU_PATH"
	if [ -e "$SECOND_MAU_PATH" ]; then
		/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -R -f -trusted "$SECOND_MAU_PATH"
	fi
fi
/usr/bin/syslog -s -l error "MSOFFICE365 - SCRIPT COMPLETE"
exit 0

The script can be adjusted based on what you comment out to install various things. I use it for both a full suite installer as well as a reinstaller for specific apps as needed.  Just modify as you see fit.