
Over the past few weeks I’ve been asked multiple times on a way that we can get an insight on our computer’s warranty expirations. This is helpful information to plan out a computer refresh cycle and to have good observability on the status of your fleet.
To date, I’ve been working on getting some processes in place similar to using the GSX integration within Jamf Pro to help obtain this information and automatically get it into the inventory of our Jamf Pro enrolled computers. This has been a lengthy process and is not yet complete.
As I was browsing through the #jamfnation channel on MacAdmins slack, I noticed a question that mentioned a plist located on a computer called Warranty.plist. As soon as I saw this I went to investigate what is stored in the plist as I had no idea it was even there. Upon looking through the preferences file, I saw the key coverageEndDate. This was the key I needed which could be extracted using a defaults read command. Now that we know we can get the information, the easy part came to build an extension attribute that can populate our computer’s inventory record with the coverage end date located in the file. Below is the EA that I have created to grab the required information.
#!/bin/bash
# This EA will grab the current logged in user and find the Warranty plist
# This is useful to grab the coverageEndDate key from the plist and provide
# a date in which warranty coverage should be ending
#
# Created 07.12.2023 @robjschroeder
# Get the current logged in user
loggedInUser=$( echo "show State:/Users/ConsoleUser" | scutil | awk '/Name / { print $3 }' )
# Find the coverage end date key in Warranty.plist
coverageEndDate=$( /usr/bin/defaults read /Users/$loggedInUser/Library/Application\ Support/com.apple.NewDeviceOutreach/Warranty.plist coverageEndDate )
# Format the EPOCH time to something readable
formattedTime=$(date -jf %s $coverageEndDate "+%F %T")
echo "<result>$formattedTime</result>"
exit 0
When adding this EA to Jamf Pro, it is recommended that the data type be switched to date. This will help to create Smart Groups that can use the operators that use the date data type.
With this EA, I’ve created reports to show all computers that have a coverage end date of more than 1 day ago. With this new information we can start planning hardware refreshes on devices that are no longer covered under warranty.
I will continue to browse this warranty.plist file to look for any important information that I can use for reporting on our hardware.
Note: In testing, this is working on Apple Silicon Macs. On Intel Macs, it doesn’t look like this plist (or at least not in this directory) exists.
I hope this information is helpful to you as much as it was to me. Thanks for checking it out!
4 responses to “Jamf Pro – Get Mac Warranty Information”
I noticed Apple has started to prefix the file with a super long GUID like string.. and added an underscore before Warranty.
I had to add an ls | grep “_Warranty” to my script to capture the full unique name of the file in to a variable, then reference that variable in my path for the file when using defaults read.
John, would you be able to please share where you’ve added that “ls”?
Thanks.
Hi GeeBee.
Here is the script in whole that accounts for the new naming convention of the Warranty file. It’s not full proof, which is why I have an echo at the end for “No Warranty File”.. just in case it’s not there. You could remove that so that if it is not there on a subsequent inventory, it would not overwrite what you already had gathered when it did work.
(SIDE NOTE – Ultimately I did go a different path altogether by using a script in a policy to run once and create a PLIST file inside the JAMF folder that contains the expiration date, and then I read that file with the EXT attribute script.. I did it this way since I decided the only way to get every Mac included was to use my own Apple Business Manager computer data export as the source data, and skip trying to use the Warranty file, which only would exist if the user was signed in with an Apple ID. So my policy script curls the data file, looks up the serial number and reads the expiration date, then creates the PLIST file for the EA to read later. – LMK if you would like to see that solution instead)
#!/bin/bash
### If Apple Care is active, there may be a file in the primary Users Library folder.
### Let’s get the current user’s username and home folder location
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk ‘{ print $3 }’`
myUserHome=$(dscl . read /Users/$loggedInUser NFSHomeDirectory | awk ‘{print $NF}’)
echo “The logged in user is “$loggedInUser
### Let’s check if the Warranty file exists
cd /Users/$loggedInUser/Library/Application\ Support/com.apple.NewDeviceOutreach/
warrantyfile=( $(ls | grep “_Warranty”))
# Loop to look at each file one at a time and stop if condition is true
for i in “${warrantyfile[@]}”
do
echo “$i”
### Let’s get the warranty expiration date in epoch seconds.
expires=`defaults read /Users/$loggedInUser/Library/Application\ Support/com.apple.NewDeviceOutreach/$i coverageEndDate`
if [ -z “$expires” ]
then echo “File has no expiration date – skipping this file.”
else
### Let’s convert epoch to a standard date format
APCexpires=`date -j -f ‘%s’ “$expires” +%b\ %d,\ %Y`
echo “$APCexpires”
exit 0
fi
done
echo “No Warranty File”
exit 0
Jon Taylor are you on the slack admin channels to contact you on the other method you provided and how to set that up for testing?