Recently Upgraded OS Smart Group

jamiesmithJAX
Contributor

I don't know if this is possible, but does anyone have a way to create a smart group where the operating system has done a major version upgrade in the past 24 hours?  

I'm prepping for a Sequoia rollout and want to have some idea of which machines upgrade each day.  I use an erase-install Self Service process for the upgrades but the policy never technically finishes as it gets killed when the Sequoia installer restarts, so I can't rely on policy logs.

3 REPLIES 3

sdagley
Esteemed Contributor II

@jamiesmithJAX Not with anything built-in to Jamf Pro, but you could have a policy triggered on login that does a recon and use a Smart Group for Macs already on Sequoia as an exclusion for your Self Service policy.

BTW, you can avoid the problem of running erase-install via a policy not allowing the policy to complete by using https://github.com/grahampugh/erase-install/blob/main/erase-install-launcher.sh as a stub script to launch erase-install instead of running it directly.

Shyamsundar
Contributor III

Consider using a Custom EA to obtain this data. You could develop a script to write the OS version to a text file daily and compare the values from the last two days. Any change in the value could indicate a macOS update. This approach enables the identification of devices receiving daily updates.

easyedc
Valued Contributor II

The software update command has a history function.  A simple script could search that list for any matches to macOS and print the last 2 columns.  Those can be reported back to Jamf as an EA and then searched against. 

softwareupdate --history
Display Name                                       Version    Date                  
------------                                       -------    ----                  
macOS Sequoia 15.2                                 15.2       12/11/2024, 16:25:04  

Just piecing something together I'd do it like this. You may need to clean it up some if you get more than one update recorded (this Mac was recently wiped/reloaded).

#!/bin/sh

#  when did OS update run.sh
#  
#
#  Created by Ed C on 1/21/25.
#  
# Get the software update history
history=$(/usr/sbin/softwareupdate --history)

# Extract the dates of macOS updates
macos_updates=$(echo "$history" | grep -E 'macOS' | awk '{print $(NF-1), $NF}')

# Get the most recent date
recent_update=$(echo "$macos_updates" | sort -r | head -n 1)

# Remove any commas from the result
recent_update=$(echo "$recent_update" | tr -d ',')

# Output the result in XML format for Jamf
echo "<result>$recent_update</result>"
Edit the script as needed to fit the need you're after, but this above will end up with a result similar to: '12/11/2024 16:25:04'