Stand by...

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

Related posts:

  1. How To: Check your computer’s IP address
  2. Apple and AT&T, still?

2 Comment(s). Add a comment or Trackback

  • Brian Kuthy  13:16 Dec 15, 2009 

    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?serialNumber= 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  09:18 Dec 22, 2009 

    It works fine for me. I’d check for errant carriage returns or spaces.

Leave a comment ↓

Welcome back, (change)

submitting...

Categories