Posted on 01-28-2013 10:03 AM
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.
Solved! Go to Solution.
Posted on 01-28-2013 10:16 AM
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>"
Posted on 01-28-2013 10:16 AM
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>"
Posted on 01-28-2013 11:31 AM
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.
Posted on 01-28-2013 11:45 AM
@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.
Posted on 01-28-2013 11:55 AM
Worked like a charm! Thank you very much! I can tweak this a bit to get other results as well.
Thanks again!
Posted on 01-28-2013 11:57 AM
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
Posted on 01-28-2013 12:07 PM
@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.
Posted on 01-28-2013 12:10 PM
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!
Posted on 01-28-2013 12:33 PM
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.