Microsoft Office 2019 Extension Attribute

joelsenders
New Contributor III

I just wanted to share this as a help to anyone, and also to see if anyone else is doing something similar (or better). I needed to be able to scope a few policies just to machines that have Microsoft Office 2019 installed (any single Office 2019 app, not necessarily all of them), and that's a bit difficult since it shares a major version number (16.x) with Microsoft Office 2016. So I wrote this extension attribute up. It will continue working as long as Office 2019 stays in the 16.2x digits, and will need to be modified if/when it hits the 16.3x versions. The testing stuff (commented out) can be removed, but if you'd like to modify it at all for other purposes the test lines can be helpful.

#!/bin/bash

#script to determine if MS Office 2019 is installed

excelversion=$(defaults read /Applications/Microsoft Excel.app/Contents/Info.plist CFBundleVersion)
onenoteversion=$(defaults read /Applications/Microsoft OneNote.app/Contents/Info.plist CFBundleVersion)
outlookversion=$(defaults read /Applications/Microsoft Outlook.app/Contents/Info.plist CFBundleVersion)
powerpointversion=$(defaults read /Applications/Microsoft PowerPoint.app/Contents/Info.plist CFBundleVersion)
wordversion=$(defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleVersion)


######
#TESTING AREA
#echo "Excel version is $excelversion"
#echo "OneNote version is $onenoteversion"
#echo "Outlook version is $outlookversion"
#echo "PowerPoint version is $powerpointversion"
#echo "Word version is $wordversion"
#
#to check for a single app version, below will identify presence of EXCEL 16.17 through 16.29:
#if [[ $excelversion = 16.2?* || $excelversion = 16.1[7-9]* ]];
#then echo "Excel 2019 Installed"
#else echo "Excel 2019 Not Installed"
#fi
######


#below will identify presence of any Office app version 16.17 through 16.29:
if [[ $excelversion = 16.2?* || $excelversion = 16.1[7-9]* || 
$onenoteversion = 16.2?* || $onenoteversion = 16.1[7-9]* || 
$outlookversion = 16.2?* || $outlookversion = 16.1[7-9]* || 
$powerpointversion = 16.2?* || $powerpointversion = 16.1[7-9]* || 
$wordversion = 16.2?* || $wordversion = 16.1[7-9]* ]] ;

#For JAMF EA:
then echo "<result>Office2019Installed</result>"
else echo "<result>Office2019NotInstalled</result>"
fi

exit 0

You can then scope a smart group to your EA with a value of "Office2019Installed". Or modify to your heart's content. :-)

7 REPLIES 7

swhps
Contributor III

Awesome!! Tweaking for the Latest Office 2019 up to 16.36.x

sdagley
Honored Contributor II

@swhps You can simplify this quite a bit by using a single regex that will match any version number higher than 16.16.x (@talkingmoose was the original poster of this regex I believe):
^16.(1[7-9].*|[2-9][0-9].*)

dan_gregson
New Contributor II

So @sdagley if I put this in a Jamf search like AND/OR CRITERIA OPERATOR VALUE

Application Title has Microsoft Word

and Application Version matches regex ^16.(1[7-9].|[2-9][0-9].)

That will give the Machines that have At least Office 2019 version of word?

sdagley
Honored Contributor II

@dan.gregson Correct, sort of... The forum software makes it very difficult to post a regex without it getting mangled, as was the one in your post. The one in my post should work as the expression to identify any Office 2019 version of Word however. At least until Microsoft comes out with whatever succeeds Office 2019.

khaledhaj
New Contributor

Is there a way to create script (or a smart group) for office o365? we have machines that are on 2016 and others on 2016 O-365. How can i tell which is on just 2016 or 2019 and which are actually o365 version of MS 2016 or 2019?  both apps will show the version Number but that does not indicate if its an O-365 2016 or just Office 2016.

 

Thanks in advance. 

Is this what you're looking for--which license type is being used? https://github.com/pbowden-msft/ExtensionAttributes/blob/master/Office_License.sh

 

jonathan_rudge
New Contributor III

Hi, @JasonAtCSUMB do you know if the EA will product machines with just Excel installed as a licence for example?


We have a mixed estate where we need to ideally have Full licence reporting vs single components of Microsoft as a result.