LANDesk – Adding Apple Warranty Data to Inventory
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/ldscan.core.data.plist. By default, this file will be empty (if it exists at all).

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.
#!/bin/bash # mac_warranty.sh # Description: Looks up Apple warranty info for this computer and adds to LANDesk custom data # # Patrick Gallagher # http://macadmincorner.com # Modified 01/11/2009 defaultsCommand="/usr/bin/defaults" plistFile="/Library/Application Support/LANDesk/data/ldscan.core.data" tmpFile="/tmp/warranty.txt" serialNum=`system_profiler SPHardwareDataType | grep "Serial Number" | awk -F ': ' {'print $2'} 2>/dev/null` app="AppleCare Protection Plan" [[ -n "${serialNum}" ]] && WarrantyInfo=`curl -k -s "https://selfsolve.apple.com/Warranty.do?serialNumber=${serialNum}&country=USA& fullCountryName=United%20States" | awk '{gsub(/\",\"/,"\n");print}' | awk '{gsub(/\":\"/,":");print}' > ${tmpFile}` # Functions getWarranty() { grep ^"${1}" ${tmpFile} | awk -F ':' {'print $2'} } getPHCovDesc() { grep ^"${1}" ${tmpFile} | awk -F ':' {'print $2'} } getCovDesc() { 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" else ${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Phone Coverage" "${phCoverageDescription}" fi # 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" else ${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Warranty Expires" "${WarrantyExpires}" fi # Serial Number ${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Serial Number" "${serialNum}" # Purchase Date.... purchaseDate=`getWarranty PURCHASE_DATE` ${defaultsCommand} write "$plistFile" "Custom Data - Mac - Warranty - Purchase Date" "${purchaseDate}" else [[ -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" fi # echos to the console defaults read "${plistFile}" exit 0
This script is based on this one from Scott Russell at Notre Dame.
No related posts.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.



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.
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.
Apple has changed their site, does this work with the new setup?
@Eric
Yes, it still works.
This script shouldn’t be too dependent on their site’s design.
Excellent!!!
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?
Thanks!
@Darin.
I thought this was like a doc.
Basically create a distribution package of the .sh.zip 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).
You are right about the “doc” – LOL
Thank you sir!
Greatly appreciated!!!
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 ld_mac_warrenty_sh.zip
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!!!
Nevermind…I figured it out!
Thanks for the “Doc”
Thanks!