Need help with script that detects the version of Outlook and then updates it if it is the correct version.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
01-04-2018
01:43 PM
- last edited
a month ago
by
kh-richa_mig
I need a script that first checks if Outlook is installed, then if it is, checks the version, if it is not the latest version of outlook 2016, it installs the update. I have it working, but I want to add one more thing. I want to make sure that the installed version is at least version 15 (Outlook 2016) before it continues. This way I can make sure it is updating outlook 2016 and not an earlier version. Here is what I have so far that works, but I just need to add the checking to make sure it as least version 15 (Outlook 2016).
!/bin/bash
app_path="/Applications/Microsoft Outlook.app"
desired_version="15.41"
Get the line, regardless of whether it is correct
version_line=$(plutil -p "${app_path}/Contents/Info.plist" | grep "CFBundleShortVersionString")
if [[ $? -ne 0 ]]; then
version_line=$(plutil -p "${app_path}/Contents/Info.plist" | grep "CFBundleVersion")
if [[ $? -ne 0 ]]; then #if it failed again, the app is not installed at that path
echo "$app_path not installed at all"
exit 123456
fi
fi
text to get the installed version number
real_version=$(echo $version_line | grep -o '"[[:digit:].]*"' | sed 's/"//g')
if [ "$real_version" = "$desired_version" ]; then
echo "$app_path $desired_version is installed"
exit 0
fi
echo "${app_path}'s version is $real_version, not $desired_version"
/usr/local/jamf/bin/jamf policy -trigger updateoutlook
exit 1
- Labels:
-
Scripts
