How to Create Extension Attribute to Output Latest macOS That Can Be Installed on That System?

myers022
New Contributor II

How to Create an Extension Attribute to output the latest macOS that can be installed on that system?
I created a script that will run through all model identifiers in the script list but it's having a lot of issues, is there an easier way to do this in JAMF?

I've been trying this with dubugs but stil can't figure it out.
My model identifier: Mac14,9
But when I run the script I get:

Model Identifier: Mac14,9

Checking Model: 5

Checking Model: 9

Array Entry for Model Identifier:

System Not Found

 

 

 

#!/bin/bash

# Read the Mac's model identifier
system_profile=$(system_profiler SPHardwareDataType)
model_identifier=$(echo "$system_profile" | awk -F': ' '/Model Identifier/ {print $2}' | tr -d ' ')

# Define the list of model identifiers and associated operating systems
model_os_list=(
    ["Mac14,5"]="macOS Ventura"
    ["Mac14,9"]="macOS Ventura"
    # Add other model identifiers and operating systems here
)

# Debug: Display the value of the model identifier
echo "Model Identifier: $model_identifier"

# Check if the model identifier exists in the list
os=""
for model in "${!model_os_list[@]}"; do
    # Debug: Display the current model in the loop
    echo "Checking Model: $model"
    
    if [[ "${model_identifier//,/}" == "${model//,/}" ]]; then
        os="${model_os_list[$model]}"
        break
    fi
done

# Debug: Display the value of the array entry for the model identifier
echo "Array Entry for Model Identifier: $os"

# Check if the operating system is found
if [[ -n "$os" ]]; then
    echo "Operating System: $os"
else
    echo "System Not Found"
fi

 

 

 




3 REPLIES 3

jamf-42
Valued Contributor

redacted 

alanwest
New Contributor III

Have you tried using this Extension Attribute from Zack Thompson?  It's what I use in many of my environments and works like a charm!

AJPinto
Honored Contributor II

I would suggest using regex and a smart group for this. Not exactly what you may be after, but it would gather the data from JAMF rather than the device and you can configure the regex for any OS version you want.