How To: Check Apple Warranty Status via ARD

How To: Check Apple Warranty Status via ARD

Here is an awesome little script by Scott Russell of the University of Notre Dame. Using the “send Unix command” in Apple Remote Desktop, it can pull the system’s serial number, send the information to Apple’s Warranty Website and then tell you if the machine is under warranty.

#!/bin/bash

# warranty.sh
# Description: looks up Apple warranty info for this computer, or one
specified by serial number on the command-line

# Written by: Scott Russell, IT Support Engineer, University of Notre
Dame
# Created on: Sat Jan 5 16:20:54 EST 2008
# Last Modified: Thu Sep 25 09:29:11 EDT 2008

###############
## GLOBALS ##
###############

WarrantyTempFile="/tmp/warranty.txt"
PlistFile="/Library/Preferences/edu.ND.DSSBranding"

if [[ $# == 0 ]] ; then
SerialNumber=`system_profiler SPHardwareDataType | grep "Serial Number"
| awk -F': ' {'print $2'} 2>/dev/null`
else
SerialNumber="${1}"
fi

[[ -n "${SerialNumber}" ]] && WarrantyInfo=`curl -k -s
"https://selfsolve.apple.com/Warranty.do?serialNumber=${SerialNumber}&countr
y=USA&fullCountryName=United%20States" | awk '{gsub(/","/,"n");print}' |
awk '{gsub(/":"/,":");print}' > ${WarrantyTempFile}`

#################
## FUNCTIONS ##
#################

GetWarrantyValue()
{
grep -w "${1}" ${WarrantyTempFile} | awk -F ':' {'print $2'}
}

###################
## APPLICATION ##
###################

echo "$(date) ... Checking warranty status"
InvalidSerial=`grep "serial number provided is invalid"
"${WarrantyTempFile}"`
#echo "InvalidSerial == ${InvalidSerial}"

if [[ -e "${WarrantyTempFile}" && -z "${InvalidSerial}" ]] ; then
echo " Serial Number == ${SerialNumber}"

PurchaseDate=`GetWarrantyValue PURCHASE_DATE`
echo " PurchaseDate == ${PurchaseDate}"

WarrantyExpires=`GetWarrantyValue COVERAGE_DATE`
echo " WarrantyExpires == ${WarrantyExpires}"

ProductDescription=`GetWarrantyValue PROD_DESCR`
echo " ProductDescription == ${ProductDescription}"
else
[[ -z "${SerialNumber}" ]] && echo " No serial number was found."
[[ -n "${InvalidSerial}" ]] && echo " Warranty information was
not found for ${SerialNumber}."
fi

exit 0

6 thoughts on “How To: Check Apple Warranty Status via ARD

  1. Brian Kuthy Reply

    I can't seem to get this to work. Did something change on Apple's website?

    Getting this…

    /bin/bash: line 5: specified: command not found
    /bin/bash: line 8: Dame: command not found
    /bin/bash: command substitution: line 22: syntax error near unexpected token `|'
    /bin/bash: command substitution: line 22: `| awk -F': ' {'print $2'} 2>/dev/null'
    curl: no URL specified!
    curl: try 'curl –help' or 'curl –manual' for more information
    /bin/bash: line 31: https://selfsolve.apple.com/Warranty.do?serialNum… Serial Number (system): W8743X05Z64&countr
    y=USA&fullCountryName=United%20States: No such file or directory
    Tue Dec 15 16:16:07 EST 2009 … Checking warranty status
    /bin/bash: line 47: /tmp/warranty.txt: Permission denied

    • Rick Reply

      The script is still working for me. Can you give details of what is failing? You might also try contacting the gentleman who wrote it, it's in the comments of the script.

  2. Derrick Reply

    Has anyone tried this lately as I can’t seem to get it to work.

    Just using the following commands gives me a blank result.
    curl -k -s “https://selfsolve.apple.com/Warranty.do?serialNumber=${SerialNumber}&country=USA&fullCountryName=United%20States

    and yes I removed errant carriage returns or spaces

    I also modified the address to the following
    curl -k -s “https://selfsolve.apple.com/agreementWarrantyDynamic.do?serialNumber=${SerialNumber}&country=USA&fullCountryName=United%20States

    also no results. Anyone got this working as of late?

    Thanks

  3. Cleanup Crew Reply

    Hi Derrick, I am no longer able to get this script to work either. Apple has made some changes on their side and it seems like it is no longer valid.

Leave a Reply