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