Friday - last edited Friday
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
Friday - last edited Friday
redacted
Friday
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!