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. :-)