My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://www.macadmincorner.com
and update your bookmarks.

Monday, November 3, 2008

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 a defaults command.

Download the script here, it shouldn't need any modification unless you want something to display differently:

#!/bin/bash
# mac_warranty.sh
# Description: Looks up Apple warranty info for this computer and adds to LANDesk custom data
#
# Patrick Gallagher
# http://patgmac.blogspot.com
# Modified 11/02/2008


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.

2 comments:

Dan Pixley said...

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 said...

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.

Monday, November 3, 2008

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 a defaults command.

Download the script here, it shouldn't need any modification unless you want something to display differently:

#!/bin/bash
# mac_warranty.sh
# Description: Looks up Apple warranty info for this computer and adds to LANDesk custom data
#
# Patrick Gallagher
# http://patgmac.blogspot.com
# Modified 11/02/2008


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.

2 comments:

Dan Pixley said...

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 said...

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.

Monday, November 3, 2008

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 a defaults command.

Download the script here, it shouldn't need any modification unless you want something to display differently:

#!/bin/bash
# mac_warranty.sh
# Description: Looks up Apple warranty info for this computer and adds to LANDesk custom data
#
# Patrick Gallagher
# http://patgmac.blogspot.com
# Modified 11/02/2008


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.

2 comments:

Dan Pixley said...

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 said...

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.