Get Office 2016 Ext Attribute

bjones
New Contributor III

Now that Office 2016 for mac is out and being used in the workplace, is there an extension attribute out there to pull the version in the JSS. I know there is one out there for Office 2011 but nothing from what i can see for 2016. Maybe there is a way to edit the existing has anyone one came up with anything.

10 REPLIES 10

mm2270
Legendary Contributor III

Just curious, but why do you need this as an Extension Attribute? Office application versions get captured natively in the computer inventory in your JSS, so why do it again in an EA?

mhasman
Valued Contributor

https://jamfnation.jamfsoftware.com/discussion.html?id=18466

McAwesome
Valued Contributor

Office 2016 is more likely to have different version numbers for each program. I've found it easier to use multiple extension attributes. Here's the one I have for Word:

#!/bin/sh
#
############################################################################
#
# Extension Attribute checks to display Microsoft Word's Version with Release number.
#
# Uses CFBundleShortVersionString because this is the "release version number of the bundle"
# Ref: https://developer.apple.com/library/IOS/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
#
#
############################################################################
#
if [ -d /Applications/Microsoft Word.app ] ; then
    RESULT=$( sudo defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleShortVersionString )
    echo "<result>$RESULT</result>"
else
    echo "<result>Not Installed</result>"
fi

You'll just need to change the application name to make it work for Excel or any of the others.

calumhunter
Valued Contributor

Why re-invent the wheel?

Its recorded in the jss inventory anyway?

donmontalvo
Esteemed Contributor III

Depends on what you need to do. If someone needs to pull a simple report, showing a list of computers with a column for an application version, you'd be hard pressed to do it any other way. I mean, sure, API can be used if you've got someone who can sit and build something for you.

Sometimes you just need to make the sausage and not get caught up in the details.

One thing is important, since EAs are read on each and every recon, is to performance test your EA before putting it into production. Prefix the command you're going to use with "time" and verify it is fast:

$ time defaults read /Applications/Microsoft Outlook.app/Contents/Info.plist CFBundleVersion
15.18

real    0m0.076s
user    0m0.037s
sys 0m0.036s

For EAs like home folder sizes, or Outlook data sizes, create a once-per-day policy that gathers the info (which can take a significant amount of time), and output the value to a file. Then use an EA to scoop up the value.

BTW, @calumhunter I haven't forgotten I owe you a couple beers. This past JNUC was not great for me, I spent a lot of time on the phone with family (sick family member) so didn't get a chance to hang. For sure next JNUC I'm'a gonna hit you up.

Don

--
https://donmontalvo.com

ukspvmalapati
New Contributor III

This will give the Outlook version installed.

!/bin/sh

if [ -d /Applications/Microsoft Outlook.app ] ; then RESULT=$( sudo defaults read /Applications/Microsoft Outlook.app/Contents/Info.plist CFBundleShortVersionString ) echo "<result>$RESULT</result>"
else echo "<result>Not Installed</result>"
fi

joelsenders
New Contributor III

Just a note, it's probably not a good idea to use the CFBundleShortVersionString info (as was suggested above by some). If you're just trying to get a rough idea of the version then that's fine of course, but we just recently had multiple versions of 16.21 released, and if you were going by the CFBundleShortVersionString info you would have missed that. The key you should be using is the one donmontalvo used above:

defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleVersion

If you're trying to identify machines that have any version of Office 2016 installed via the extension attribute, I would suggest maybe doing something like this:

wordversion=$(defaults read /Applications/Microsoft Word.app/Contents/Info.plist CFBundleVersion)

if [[ $wordversion = 15.* || $wordversion = 16.[0-9].* || $wordversion = 16.1[0-6]* ]];
then echo "<result>Office2016Installed</result>"
else echo "<result>Office2016NotInstalled</result>"
fi
exit 0

I just wrote that up so it probably needs some testing. But the goal is to find any version of Office 15.x or Office 16.0-16.x., as so to exclude Office 16.17 and later (Office 2019).

talkingmoose
Moderator
Moderator

Here's a different way to get the same thing but without creating a new extension attribute.

Office 2016 for Mac versions are 15.9 through 16.16.x (where "x" is a number that'll just keep counting up until October 2020 when the product reaches its end of life). Office 2019 for Mac versions are 16.17 and higher.

As part of inventory, Jamf Pro is already collecting this version information, but we've had no simple way to define what versions make up "Office 2016" vs. "Office 2019". We've been having to make complex Smart Groups with multiple criteria using is/like operators and and/or conditionals.

Jamf Pro 10.7 introduced regex pattern matching in Smart Computer Groups. With one regex pattern, we can match against anything in our existing inventory. This means your Smart Computer Group results will be immediate instead of having to wait for all your Macs to report inventory, which by default is up to a week.

This regex pattern should match Office 2019: ^16.(1[7-9].*|[2-9][0-9].*)
This regex pattern should match Office 2016: ^1(5.*|6.(9$|9.1|1[0-6].*))

(FYI, there are other ways to construct this regex pattern. Some are longer and easier to read. Some are shorter and more complex. So long as you validate your pattern works, it doesn't matter how long/short or simple/complex it is.)

I can validate this against a random list of possible versions by using the Patterns app (or online at https://regex101.com). Highlighted items match the regex pattern.

a27cb1f986864fa4a694d59f41c80369

And I can use it in my Smart Group as the Application Version where the operator matches a regex pattern:

4e35dd188efc4552b926dbb1e3b25c8e

SGN
New Contributor III

@talkingmoose : Above smart group /regex pattern is only showing the list of assets ... How do we get the version of office towards to the asset .

talkingmoose
Moderator
Moderator

@SGN, the purpose of Smart Groups is to create a list of devices that match the criteria you specify. They're not for reporting purposes necessarily. I suggest you navigate to the Patch Management section under Computers and add the Microsoft Office patch title to your list of watched titles. Then check the box at the top to view it on your Dashboard or view it right there. It'll give you a list of all the versions in your environment and you can click the links to view the Macs with the specific versions.