You need to update the inventory after the OS changes. A simple bit of code like the one shown, ran at startup would work...
# Get the OS on the Mac
OS_Version=$( sw_vers -productVersion )
# Check if the OS matches our logged one, do a recon if it doesn't.
if [ -f /Library/MacSD/os_version ]; then
Recorded_Version=$( cat /Library/MacSD/os_version )
if ! [ ${Recorded_Version} == ${OS_Version} ]; then
/usr/local/bin/jamf recon
echo ${OS_Version} > /Library/MacSD/os_version
else
echo "This Mac has rebooted but no OS change found. No recon necessary."
fi
else
echo ${OS_Version} > /Library/MacSD/os_version
fi
Thanks for this. I just tried this on a test machine, but got the following error?
Script result: /Library/Application Support/JAMF/tmp/Run Inventory after macOS Upgrade: line 14: /Library/MacSD/os_version: No such file or directory
Do you know what I am doing wrong?
Hi Marcchapman
MacSD is a directory we create to store all of the little scripts and icons we use. So the folder won't exist in your environment. Adding a "mkdir /Library/MacSD" to the script or changing the path for the os_version file would resolve the error.