Get OS Build Version via Extension Attribute

cfritzy
New Contributor

I can see that you can pull the OS Build version by running "sw_vers -BuildVersion" from Terminal. I would like to gather the output of this or all the info from "sw_vers" as an extension attribute to build smart groups on. What would be the best way to get this into extension attributes? I see you can build it via a script but still getting into OS X scripting and any help would be appreciated.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Define a variable in your script that has the command run that gets that information as its result. In the Extension Attribute you echo back the above variable contained within <result> & </result> tags surrounded in quotes. Make sure to use the variable name with a "$" in front within the echo line

#!/bin/sh
OSbuild=`sw_vers -buildVersion`
echo "<result>$OSbuild</result>"

View solution in original post

8 REPLIES 8

mm2270
Legendary Contributor III

Define a variable in your script that has the command run that gets that information as its result. In the Extension Attribute you echo back the above variable contained within <result> & </result> tags surrounded in quotes. Make sure to use the variable name with a "$" in front within the echo line

#!/bin/sh
OSbuild=`sw_vers -buildVersion`
echo "<result>$OSbuild</result>"

franton
Valued Contributor III

What mm2270 suggests will work, but I'm curious why you need this as an extension attribute? This info is reported separately in the inventory, certainly in Casper 8.62.

mm2270
Legendary Contributor III

@franton, yep, it shows up in the details section of a computer inventory. For some reason though you can't add a column displaying it in a search, unless I'm just missing it.
And the trick to actually building a query or a Smart group on that information is to just use the "OS Configuration Information > Operating System Version > is" or "is like" and then the build version string, such as "11G63" for all 10.7.5 Macs. It'll pull them up, but again, you can't display the column in a search result. The OP may want to have that for overall reports and the EA would give him that ability.

cfritzy
New Contributor

Worked like a charm! Thank you very much! I can tweak this a bit to get other results as well.

Thanks again!

cfritzy
New Contributor

I was trying to build a Smart Group with the actual OS build numbers as some people have 10.8.2 and some don't have Supplemental Update 2 and wanted to target those and didn't see a way to build the Smart Group based on build number

mm2270
Legendary Contributor III

@cfritzy, as I said, its not so obvious, but it should work to plug the build you are or aren't trying to match into the "OS Configuration Information > Operating System Version > is" under criteria. It does work, at least in most cases.

cfritzy
New Contributor

I'll give it a shot. I am running 8.62 so I will try it out. Thanks again all for the information, very helpful!

chris_kemp
Contributor III

Good stuff. I did a similar thing here to re-create the OS X version with an indicator of whether the machine is running in 32- or 64-bit mode.