Extension Attributes to get the Model Identifier and Model ID Version number

NickKoval
Contributor
Contributor

The following scripts work on Lion to grab the Model Identifier and also to strip out all but the Model Identifier Version number. To assist in the creation of smart groups, I'd recommend making the Model ID version number an integer. These have been tested under Mac OS X Lion only.

Good Luck and happy reconnoitering.

Model Identifier:

#!/bin/sh

echo "<result>$(system_profiler SPHardwareDataType | grep "Model Identifier" | awk '{print $3}')</result>"

Model Identifier Version number:

#!/bin/sh

echo "<result>$(system_profiler SPHardwareDataType | grep "Model Identifier" | tr -d [A-Z][a-z]:' ' | awk -F , '{print $1}')</result>"
3 REPLIES 3

mm2270
Legendary Contributor III

You can also get the Model Identifier using ioreg, which is a bit faster than invoking System Profiler, like so-

ioreg -c IOPlatformExpertDevice | awk -F"= " '/model/{ print $2}' | sed -e 's/<"//;s/">//'

rmanly
Contributor III

and just another tip anytime you find yourself doing

grep foo | awk

or

grep foo | sed

Do this instead

awk '/foo/{ print $3 }'

:)

donmontalvo
Esteemed Contributor III

@mm2270

sysctl -n hw.model
--
https://donmontalvo.com