Splitting Up Office 2016 and 2019 In Smartgroups

McAwesome
Valued Contributor

Office 2016 and 2019 both use the same 16.X.X versioning right now, so my previous Office 2016 Installed smart group includes both Office 2016 and 2019. This didn't really matter before since I was only putting 2019 on completely new machines on 10.14. Now that we're prepping for wider deployment, I need to be able to track which machines have Office 2016 and 2019 separately.

Is there a good way to build a smart group that includes only Office 2019 installs?

1 ACCEPTED SOLUTION

mjhersh
Contributor

I'm using regex to parse out the version number. For 2019 I'm using this:

^(16.[2-9]d.)|(16.1[7-9].)

That will match 16.17, 16.18, 16.19, and any 2-digit number from 16.20-16.99.

View solution in original post

7 REPLIES 7

mjhersh
Contributor

I'm using regex to parse out the version number. For 2019 I'm using this:

^(16.[2-9]d.)|(16.1[7-9].)

That will match 16.17, 16.18, 16.19, and any 2-digit number from 16.20-16.99.

LeidenUniv
New Contributor III

it would be nice to have a 'less than" or "greater than" option in "Application-version". Just like it exists in "Operating System Version"
Office 2016 < 16.17
Office 2019 > 16.16

stevewood
Honored Contributor II
Honored Contributor II

@LeidenUniv I agree that we should have that capability, and if you do not want to use the regex method above, go vote up the FR to have this added:

Smart computer group application version compare with greater than & less than

However, you'll note that Jamf is reporting this as partially implemented with Patch Reporting. Although I would argue that this does not provide the capability for enough software titles, I shouldn't have to create a Patch Management entry just to compare versions that are stored in the Applications table, and I shouldn't have to stand up an internal patch server to be able to get the other titles in.

ryan_ball
Valued Contributor

I started down the regex path but figured that since MS could change their version scheme whenever - the regex could get pretty complicated quickly. I decided to create an Extension Attribute for this instead.

#!/bin/bash

wordVersion=$(defaults read "/Applications/Microsoft Word.app/Contents/Info.plist" CFBundleShortVersionString)
majorVersion=$(awk -F '.' '{print $1}' <<< "$wordVersion")
minorVersion=$(awk -F '.' '{print $2}' <<< "$wordVersion")

if [[ $majorVersion -ge "15" ]]; then
    if [[ "$majorVersion" -ge "16" ]] && [[ "$minorVersion" -ge "17" ]]; then
        echo "<result>2019</result>"
    else
        echo "<result>2016</result>"
    fi
else
    if [[ -d "/Applications/Microsoft Office 2011/" ]]; then
        echo "<result>2011</result>"
    else
        echo "<result>Not Installed</result>"
    fi
fi

exit 0

Then your smart groups would be "Office Version" (if that is what you called the EA) "is 2016" or "is 2019". This could be changed pretty easily too if MS decided to change version schemes again.

talkingmoose
Moderator
Moderator

While Jamf could try to build in smarts for 'greater than' and 'less than' for version numbers, keep in mind version numbers aren't really numbers. They're strings. Strings might include multiple decimals (there's no such thing as a number with more than one decimal) or non-numeric characters like 'v1' or 'b' for beta.

When dealing with version numbers, using regex as @mjhersh suggested is really the best method.

To help me with regex, I purchased Patterns from the Mac App Store for US$2.99. It lets me paste in a sample of what I need to match and provides a regex guide. I can test my regex in the app and watch it highlight my sample text live. It's a handy little tool.

2cd6a54c590f441fa274e1b89ebeef41
bc4e1c2e6fde438bab61e9fbf0660933

The https://regex101.com site is a similar online tool and it's free.

Learning a little regex is a good way to make use of read-only Fridays. And it's like solving a puzzle, so it's fun.

jonathan_rudge
New Contributor III

How do folk report on licence compliance? I get you can do a smart group but I want to add the licences and report how many we are using etc?

Thanks

SGN
New Contributor III

@Mjhersh: I just tried to follow the above regex for the office 2013 version 14.X.

^(16.[2-9]d.)|(16.1[7-9].)

But didn't get any result. Can you help me with exact regrex for the office version 14.X