Skip to main content
Solved

Find Application version through terminal / Deploying Office 2016 updates


Forum|alt.badge.img+12
  • Contributor
  • 288 replies

Hi all,

I'm looking for a way to find Microsoft Office 2016 application version numbers through terminal. I will be using this in a script to push updates.

I'm thinking of having 4 scripts (one for each Office product - excel, word, ppt, outlook), and 4 Policies that have triggers to install each program. Ideally, the script will look for Application versions, if the version found is outdated, it'll trigger the JSS Policy to install the office pkg.

Currently, we use smart groups that search for outdated version numbers and sort by departments, and it's a pain to change 50+ smart groups (due to the large amount of departments we have) when a new version comes out. We want to retain the option of doing by deploying by department.

Best answer by mm2270

Using defaults:

defaults read /Applications/Microsoft Word.app/Contents/Info CFBundleShortVersionString

Using mdls (Spotlight's command line interface - for info):

mdls /Applications/Microsoft Word.app -name kMDItemVersion | awk -F'"' '{print $2}'

Either one should report back the version, assuming the app is in the path you specify, otherwise you'll get an error. So just be sure to do a check for the application existing before trying to get the version.
You could also locate the application path using mdfind (Spotlight's command line search interface)

mdfind -onlyin /Applications -name "Microsoft Word"
View original
Did this topic help you find an answer to your question?

10 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • Answer
  • December 4, 2015

Using defaults:

defaults read /Applications/Microsoft Word.app/Contents/Info CFBundleShortVersionString

Using mdls (Spotlight's command line interface - for info):

mdls /Applications/Microsoft Word.app -name kMDItemVersion | awk -F'"' '{print $2}'

Either one should report back the version, assuming the app is in the path you specify, otherwise you'll get an error. So just be sure to do a check for the application existing before trying to get the version.
You could also locate the application path using mdfind (Spotlight's command line search interface)

mdfind -onlyin /Applications -name "Microsoft Word"

Forum|alt.badge.img+14
  • Contributor
  • 388 replies
  • December 4, 2015
mdls -name kMDItemVersion /Applications/Microsoft Word.app

This would give the version number, would this work?

Mike beat me to it.


Forum|alt.badge.img+12
  • Author
  • Contributor
  • 288 replies
  • December 4, 2015

This is perfect! Thanks for the quick response guys!


Forum|alt.badge.img+10
  • New Contributor
  • 596 replies
  • December 7, 2015

Isn't casper supposed to help you not need to deploy scripts to do this kinda stuff?


Forum|alt.badge.img+10
  • Valued Contributor
  • 230 replies
  • October 14, 2016

A note for myself more than anything - if you need to identify the long version string, say, for a smart group or something, you can use this defaults command to retrieve it:

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

While this is obviously not specific to Office 2016, the context in which I arrived here was needing to identify Microsoft Office 2016 installed version for a smart group to be upgraded.


donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • October 14, 2016

Vendors can make mistakes, or conscious decisions, that change how/where their version information is stored. Microsoft recently flip flopped between CFBundleVersion and CFShortBundleVersionString and anyone who depends on accuracy of that string might have been bit.

Not sure I would trust/rely on mdls for anything more than baseline reporting, like "Computer XYZ has an unpatched version of Google Chrome in /Users/jdoe/Desktop/Google Chrome.app", which support teams can rectify.

Users having admin rights, users not adhering to corporate mandates...may as well have a vi vs pico vs nano debate. ¯_(ツ)_/¯


donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • May 12, 2020

Circling back to correct my post, er, to admit I was wrong. @tlarkin suggested it isn't fragile, and since trying it, found myself hooked to it. Not a single failure.


Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • May 27, 2020

Pro tip with mdls use the -raw switch to only output the result and you don't have to awk, grep or sed stuff


Forum|alt.badge.img+10
  • Valued Contributor
  • 108 replies
  • July 6, 2020

Does anyone know what extra command(s) would be added to incorporate this into a script to populate the version of an app as an extension attribute and if it's not installed, to populate "Not Installed"?


Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • July 7, 2020

some Spotlight examples that may or may not help, but I think they are nifty

This just returns anything tagged as an app, its file path, display name and version

mdfind -0 -onlyin /Applications "kMDItemKind == Application" | xargs -0 mdls -name kMDItemPath -name kMDItemDisplayName -name kMDItemVersion

you can get more specific if you wish, like this will use bundle ID to identify Microsoft apps

mdfind -0 -onlyin /Applications "kMDItemKind == Application && kMDItemCFBundleIdentifier = com.microsoft.*" | xargs -0 mdls -name kMDItemPath -name kMDItemDisplayName -name kMDItemVersion

This might be a bit cleaner in Python since you can build dictionary values or deal with structured data sets. You could also pipe this into a associative array in zsh I suppose as well.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings