How to tell if a machine can run an OS.

ctangora
Contributor III

So while it is easy to see if a machine's specs COULD run an OS, it is not as easy as it sounds. Since newer models won't run older OS's, you can't simply say that if the EFI bit is 64, then it can run Mac OS 10.8 (because newer systems won't run it).

Is anyone out there creating a smart group that is scoped to what OS a machine could run?

Short of excluding specific models, wondering if someone figured something out I haven't yet.

Thanks.

12 REPLIES 12

scottb
Honored Contributor

I will be trying to do this but for a different reason - to scope a group for new hardware to install the free iWork on. Since it's likely going to be Self Service, I don't necessarily trust honesty, so I was thinking by using "sysctl hw.model" in an xatt or something? Taking that info and then making a group, you could in theory - after you do the hard work of gathering the info (MacTracker is a good app). Might be other and better ways, but that's how I was going to start...

ezemke
New Contributor III

This might be helpful?

http://support.apple.com/kb/HT1159

krichterjr
Contributor

I have some smart groups built based only on is and is not for specific models. Our environment is fairly simple though so it wasn't too difficult.

johnnasset
Contributor

+1 for Mactracker.

mm2270
Legendary Contributor III

Agreed. The best place I know where this information exists is Mactracker, although it may not be the *only* place.

Its interesting, because what you need to know is what the Minimum and Maximum OS a piece of hardware can run is, which just isn't something the hardware itself can really tell you. OS X installers have their Supported models lists that you can cull information from, but nothing like that for the OS versions it can boot from exists on the Mac itself, as far as I know.
You're probably going to beed to build a script that gets the Mac's model identifier and loops through and figures out the min and max OS based on information from Mactracker.
I wish there was an online version of Mactracker, but as far as I know, the information it has is contained in the app itself and nowhere else that you can point the Mac to

laurendc
New Contributor

@ezemke][/url][/url This is what I use - it's a great reference. +1 for the apple link

Now that I think about it, the smart groups could be scoped to the build number linked to the machine? Probably using system_profiler would do it.

Update: Just tinkered for a minute, found that this will do it: ```
sw_vers -buildVersion
```

Then you could create extension attribute to grab that information and the smart groups could be based on those build versions?

scottb
Honored Contributor

@laurendc][/url: That tells you the build of the OS on the Mac - not sure how that helps here?
What you need is the Mac model identifier (sysctl hw.model) then scope to the Macs that can run what OS X iteration. As an example, a rMBP 11,2 released in late 2013 shipped with 13A3017 (10.9). You know then that this model can run 10.9+ and not ?10.8.x.

I think the OP is trying to find the minimum OS X a particular Mac can run, and that would be doable using that xatt I'd think...

ctangora
Contributor III

Yea, half looking for what machines can be downgraded to an OS and half looking to see what machines can be upgraded to an OS.

ctangora
Contributor III

Took your suggestions and wrote two scripts. One says if it can run 10.9, one says if it can run 10.8.

I don't have test machines with me today, but if someone sees an error in this let me know. Otherwise this can be used in an EA (XAtt) to get you a list of machines that are compatible with the two OS's.

Pardon my lack of commenting... tried to rush this one.

#!/bin/bash

## Checks to see if Machine is compatible with Mac OS 10.8
hw_model=`sysctl hw.model | awk '{ print $2 }'`

mod_name=`echo $hw_model | tr -cd [[:alpha:]]`
mod_majver=`echo $hw_model | awk -F "," '{ print $1 }' | tr -cd [[:digit:]]`
mod_minver=`echo $hw_model | awk -F "," '{ print $2 }'`

## Find Machine And Report Back
case "$mod_name" in 
    iMac* )
    echo "iMac"
        if [[ $mod_majver -ge 7 ]] && [[ $mod_majver -lt 15 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacBookPro* )
    echo "MBP"
    if [[ $mod_majver -ge 5 ]] && [[ $mod_majver -lt 11 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    Xserve* )
    echo "XS"
        if [[ $mod_majver -ge 3 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacBookAir* )
    echo "MBA"
        if [[ $mod_majver -ge 2 ]] && [[ $mod_majver -lt 7 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    Macmini* )
    echo "Mm"
        if [[ $mod_majver -ge 3 ]] && [[ $mod_majver -lt 7 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacPro* )
    echo "MP"
        if [[ $mod_majver -ge 3 ]] && [[ $mod_majver -lt 6 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacBook* )
    echo "MB"
        if [[ $mod_majver -ge 5 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi

    ;;
    * )
    echo "<result>Error</result>"
    ;;
esac
exit 0
#!/bin/bash

## Checks to see if Machine is compatible with Mac OS 10.9

hw_model=`sysctl hw.model | awk '{ print $2 }'`

mod_name=`echo $hw_model | tr -cd [[:alpha:]]`
mod_majver=`echo $hw_model | awk -F "," '{ print $1 }' | tr -cd [[:digit:]]`
mod_minver=`echo $hw_model | awk -F "," '{ print $2 }'`


## Find Machine And Report Back

case "$mod_name" in 
    iMac* )
        if [[ $mod_majver -ge 7 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacBookPro* )
        if [[ $mod_majver -ge 5 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    Xserve* )
        if [[ $mod_majver -ge 3 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacBookAir* )
        if [[ $mod_majver -ge 2 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    Macmini* )
        if [[ $mod_majver -ge 3 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacPro* )
        if [[ $mod_majver -ge 3 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    MacBook* )
        if [[ $mod_majver -ge 5 ]]; then
            echo "<result>Compatible</result>"
        else
            echo "<result>Not Compatible</result>"
        fi
    ;;
    * )
    echo "<result>Error</result>"
    ;;
esac

exit 0

HAVE A GREAT WEEKEND!

Chris

scottb
Honored Contributor

@ctangora: Chris, cool - on first runs, the 10.9 and 10.8 scripts worked on two Macs I have here. Very cool. I'll test more out over the weekend and report back. Thanks for doing the part that I'm not so good at ;)

Have a good weekend,
Scott

timsutton
Contributor

And if you are interested in a mechanism that's able to tell you if a machine can be upgraded to a particular major version of OS X, Hannes Juutilainen has done the most thorough work I'm aware of for this. He has written scripts that perform the same logic as the actual OS X installers.

I'm not sure if this is useful to the OP as-is, since I'm not sure he ever said exactly why he'd like to know what OSes a machine could run.

https://github.com/hjuutilainen/adminscripts/blob/master/check-mountainlion-compatibility.py

https://github.com/hjuutilainen/adminscripts/blob/master/check-mavericks-compatibility.py

Mauricio
Contributor III

I have been working on a solution to check if the Mac can be upgraded to Mavericks.
We have over 4000 Macs with all possible OSs and models and we have started a consolidation project to bring all of them to 10.9 (and later).
The list of models are in this Apple's article "OS X Mavericks: System Requirements".
http://support.apple.com/kb/ht5842

The script I created excludes servers as our focus is desktop side only.
As the serial number is needed to get the model some checks has to be done or you could have a "serial number not available" group and exclude it from your policy.
There is one other check which if the Mac is running Mavericks. Again you could have that filtered before.

Hope this can be useful to you.

#!/bin/sh

################################################################################
#
# Copyright (c) 2014, Mauricio Pellizzon.
# 
################################################################################
#
# ABOUT THIS PROGRAM
#
# NAME
#   MacModelValidation.sh
#
#
# DESCRIPTION
#   This script will check if the Mac can be upgraded to Mavericks.
#   Apple's OS X Mavericks: System Requirements is at http://support.apple.com/kb/ht5842
#
#   Servers have been excluded from the checks as they are out of our scope.
#   A check is done to see if Mac is already running Mavericks.
#   This script will need to be updated with the next OS release.
#
################################################################################
#
# HISTORY
#
#   Version: 1.0
#
#   - Created by Mauricio Pellizzon 25/04/2014
#
################################################################################
# 
# SCRIPT CONTENTS
#
################################################################################

macOS=`defaults read /System/Library/CoreServices/SystemVersion ProductVersion | awk -F "." '{print $2}'`


if [ $macOS -ge 9 ]; then

    echo "<result>Mac is already running Mavericks.</result>"

else

    serialNumber=`system_profiler SPHardwareDataType | awk '/Serial Number/ { print $4; }'`
    if [ -n "$serialNumber" ]; then
    # There is a serial number, some old models that have been mother board repaired/replaced may not have a serial number.
    # Further checks need to be done to capture other possible outputs.

        if [ "$serialNumber" = "System Serial#" ]; then 
            echo "<result>Unable to get the serial number.</result>"
            exit 1
        fi
    fi

    macSerialD=`echo "$serialNumber"| cut -c 9-`
    modelSearch=`curl -s "http://support-sp.apple.com/sp/product?cc=$macSerialD" | sed 's|.*<configCode>(.*)</configCode>.*|1|'`

    if [ -n "$modelSearch" ]; then

        echo "<result>${modelSearch}</result>"

        if [[ "$modelSearch" == *Server* ]] || [[ "$modelSearch" == *Xserve* ]] ; then
          echo "<result>This is a server, it is out of scope.</result>"
        else
            if [[ "$modelSearch" == *,* ]]; then
              macSize=`echo "$modelSearch" | awk -F "(" '{print $2}' | awk -F "," '{print $1}'` 
            fi

        macYear=`echo "$modelSearch" | awk -F " " '{print $NF}' | sed 's/)//'`
        macSeason=`echo "$modelSearch" | awk -F " " '{print $(NF-1)}'| sed 's/(//'`
        macModel=`echo "$modelSearch" | awk -F "(" '{print $1}' | sed 's/[ 	]*$//'`

        fi

            function validateSeason {

                case ${Season} in
                    Early )  macUpgrade="YES" ;;
                    Mid )  if [ ${macSeason} == Early ] ; then macUpgrade="NO"; else macUpgrade="YES"; fi; ;;
                    Late ) if [ ${macSeason} == Late ] ; then macUpgrade="YES"; else macUpgrade="NO"; fi; ;;
                esac
            }

            function validateYear {

                if [ $macYear -gt $Year ] ; then
                    macUpgrade="YES"
                else
                    if [ $macYear -eq $Year ] ; then
                        validateSeason
                    else
                        macUpgrade="NO"
                    fi
                fi
             }

        case ${macModel} in
             "iMac" ) Year=2007 Season="Mid" validateYear ;;
             "MacBook" )  if [ "${macSize}" == "13-inch Aluminum" ]; then Year=2008 Season="Late"; else Year=2009 Season="Early" ; fi;  validateYear ;;
             "MacBook Pro" ) if [ "${macSize}" == "13-inch" ]; then Year=2009 Season="Mid"; else Year=2007 Season="Late" ; fi;  validateYear ;; 
             "MacBook Air" )  Year=2008 Season="Late" validateYear ;;
             "Mac mini" ) Year=2009 Season="Early" validateYear ;; 
             "Mac Pro" ) Year=2008 Season="Early" validateYear ;;
        esac

        # It will report if Mac can be upgraded to Mavericks as YES or NO, adapt macUpgrade to your needs.
        echo "<result>${macUpgrade}</result>"
    else
        echo "<result>No model returned.</result>"
    fi

fi

################################################################################

exit 0

Regards
Mauricio