LANDesk – Adding Apple Warranty Data to Inventory

by on November 3, 2008 » Add more comments.

Virtually any data can be added to the LANDesk inventory for a given machine by adding values to the file /Library/Application Support/LANDesk/data/ By default, this file will be empty (if it exists at all).

LANDesk Warranty Data
Adding Apple warranty data is just a matter of looking up the machines serial number against Apple’s warranty records and adding the results with defaults commands.

Download the script here, it shouldn’t need any modification unless you want something to display differently. The code shown below might not work properly because of line breaks.

# Description: Looks up Apple warranty info for this computer and adds to LANDesk custom
# Patrick Gallagher
# Modified 01/11/2009
plistFile="/Library/Application Support/LANDesk/data/"
serialNum=`system_profiler SPHardwareDataType | grep "Serial Number" | awk -F ': ' {'print
$2'} 2>/dev/null`
app="AppleCare Protection Plan"
[[ -n "${serialNum}" ]] && WarrantyInfo=`curl -k -s
fullCountryName=United%20States" | awk '{gsub(/\",\"/,"\n");print}' | awk
'{gsub(/\":\"/,":");print}' > ${tmpFile}`
# Functions
	grep ^"${1}" ${tmpFile} | awk -F ':' {'print $2'}
	grep ^"${1}" ${tmpFile} | awk -F ':' {'print $2'}
	grep ^"${1}" ${tmpFile} | awk -F ':' {'print $2'}
InvalidSerial=`grep "serial number provided is invalid" "${tmpFile}"`
if [[ -e "${tmpFile}" && -z "${InvalidSerial}" ]] ; then
	# Is there phone coverage available?
	phCoverageDescription=`getPHCovDesc PHCOVERAGE_DESC`
	if [ "$phCoverageDescription" == "${app}" ]; then
		${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Phone
Coverage" "Available - Call 800-800-2775"
		${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Phone
Coverage" "${phCoverageDescription}"
	# Type of coverage
	coverageDescription=`getCovDesc COVERAGE_DESC`
	${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Coverage
Description" "${coverageDescription}"
	# Warranty Expires...
	WarrantyExpires=`getWarranty COVERAGE_DATE`
	if [ "${WarrantyExpires}" == "" ]; then 
		${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Warranty
Expires" "Expired"
	${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Warranty Expires"
	# Serial Number
	${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Serial Number"
	# Purchase Date....
	purchaseDate=`getWarranty PURCHASE_DATE`
	${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Purchase Date"
	[[ -z "${serialNum}" ]] && ${defaultsCommand} write $plistFile "Custom Data - Mac -
Serial Number" "Error getting serial, Logic board replaced?"
	[[ -n "${InvalidSerial}" ]] && ${defaultsCommand} write $plistFile "Custom Data - Mac -
Warranty Expires" "Not Found"
# echos to the console
defaults read "${plistFile}"
exit 0

This script is based on this one from Scott Russell at Notre Dame.

Find more like this: Automation, Hardware, LANDesk, Mac, Scripting , , , , ,

10 Responses to LANDesk – Adding Apple Warranty Data to Inventory

  • Dan Pixley says:

    Hey, thanks for reading my LANDesk blog, and the clarification. I was curious if you’ve messed with OSD for Macs via LANDesk? I only do the PC side of it, but my coworkers have been having a hard time getting this stuff to work. They already have a Net Restore server and infrastructure, but integrating it into LANDesk has been challenging for them.

  • Patrick Gallagher says:

    Hi Dan. No, I haven’t messed with LANDesk’s Mac OSD. From what I could tell from their PDF, it’s just injecting a service into Apple’s NetInstall to get updates on the status of the imaging and to inject computer names from the database and probably the agent. Their PDF doesn’t really say what their Xserve installers actually do.

    I haven’t seen any advantage to having LANDesk in the mix. We are a NetRestore shop as well but will probably be moved over to Deploy Studio within a couple weeks.

  • Eric says:

    Apple has changed their site, does this work with the new setup?

  • Patrick says:


    Yes, it still works.

    This script shouldn’t be too dependent on their site’s design.

  • Darin says:


    Patrick, we just started looking at the Mac side of the house…do you have a doc on this process?

    What steps need to be taken?


  • Patrick says:


    I thought this was like a doc. 🙂

    Basically create a distribution package of the file. Then create a scheduled task to push out to all your Macs (use a query for this) at whatever interval you wish (I think I did monthly).

    We’ve actually moved our Macs off LANDesk and onto Absolute Manage (formerly LANrev).

  • Darin says:

    You are right about the “doc” – LOL

    Thank you sir!

    Greatly appreciated!!!

  • Darin says:

    So…a couple of questions as I started down this path.

    1. The link in the “doc” to download is broken…
    2. I copied the script and saved it as
    3. I tried to create a distribution package, but LANDesk didn’t like the file. I tried Mac package, SWD package, exe package and none of them worked.
    4. Do I also need to create a plist file?

    Any help would be appreciated!

    Thanks in advance!!!

  • Darin says:

    Nevermind…I figured it out!

    Thanks for the “Doc” 🙂


  • Pingback: Absolute Manage – Adding Dell Warranty to Inventory | Mac Admin Corner

Leave a Reply

Your email address will not be published. Required fields are marked *