Posted on 03-26-2019 11:15 AM
I'm trying to make a smart group of macOS devices with Office 2019 installed. I'm trying to use a regex on the version number to differentiate between Office 2016 (16.16.x) and 2019 (16.17.x-16.2x.x).
The regex is ^16.([0-9]|1[0-6]).d
According to regex101.com, my regex is fine. However, when I try to save the smart group, Jamf throws me an error 'Uneven number of opening and closing parenthesis'. Does anyone have any ideas why Jamf is being cranky with my expression?
Solved! Go to Solution.
Posted on 03-26-2019 11:28 AM
Can you post a screenshot of how you've set up the actual Smart Group? The error you're getting may not have anything to do with the regex pattern. Usually that means you have some parenthesis around some of the criteria options that aren't jiving with what Jamf Pro expects.
I just used what you posted in a Smart Group as shown below, and it saved fine for me (on Jamf Pro 10.10.1), and shows machines that match the criteria. But notice no parenthesis on the arrowed drop down menus. Maybe you have one of those on and the closing one off?
Edit: FWIW, I agree with @ryan.ball that using an EA to gather this is probably more reliable. Not that you shouldn't explore using regex patterns in Smart Groups - it's a powerful and useful feature - but an EA probably is better for this particular use case, and in fact I use something similar to what he is doing. But I'm not checking for Office 2011 since I don't have a need for that myself.
Posted on 03-26-2019 11:25 AM
I went down that route but found it too fragile and without knowing what MS would do with versioning in the future (it is odd already). I went with an EA as it is pretty easy to change the script around if versions change so you don't get into the issue you are in now when they change again.
#!/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
Posted on 03-26-2019 11:28 AM
Can you post a screenshot of how you've set up the actual Smart Group? The error you're getting may not have anything to do with the regex pattern. Usually that means you have some parenthesis around some of the criteria options that aren't jiving with what Jamf Pro expects.
I just used what you posted in a Smart Group as shown below, and it saved fine for me (on Jamf Pro 10.10.1), and shows machines that match the criteria. But notice no parenthesis on the arrowed drop down menus. Maybe you have one of those on and the closing one off?
Edit: FWIW, I agree with @ryan.ball that using an EA to gather this is probably more reliable. Not that you shouldn't explore using regex patterns in Smart Groups - it's a powerful and useful feature - but an EA probably is better for this particular use case, and in fact I use something similar to what he is doing. But I'm not checking for Office 2011 since I don't have a need for that myself.
Posted on 03-26-2019 11:40 AM
That was my problem! I got too focused on the regex and forgot that I started by cloning a smart group and altering the criteria. The one I cloned from used the dropdown parenthesis.
Thanks!