Powershell script to query Dell website for Warranty End Date

This little powershell script uses WMI to get the local PCs Service Tag from the bios.  It then queries Dell’s website for the warranty information and loops through each warranty line item to find the latest date.  Once we have the date, it is then written to the registry.  The warranty end date is then ready to be used in BGInfo or exported to a MOE tool such as Altiris NS for easy reporting.

[System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)

[String]$ServiceTag = $(Get-WmiObject -Class “Win32_Bios”).SerialNumber
$AssetService = New-WebServiceProxy -Uri “http://xserv.dell.com/services/AssetService.asmx?WSDL”;
$ApplicationName = “AssetService”;
$Guid = [Guid]::NewGuid();
$Asset = $AssetService.GetAssetInformation($Guid,$ApplicationName,$ServiceTag);
$Writer = New-Object “System.IO.StringWriter”;
$XmlSerializer = New-Object System.Xml.Serialization.XmlSerializer($Asset.GetType());
$XmlSerializer.Serialize($Writer,$Asset);
[String]$Result = $Writer.ToString();
$Writer.Flush();
$Writer.Close();

[xml]$dellinfo = $Result

foreach ($set in $dellinfo.ArrayOfAsset.Asset.Entitlements.EntitlementData)
{
    [DateTime]$date = Get-Date $set.EndDate
    if ($date -gt $maxdate)
    {
            $maxdate = $date
    }
}

#[System.Windows.Forms.MessageBox]::Show($maxdate.ToShortDateString(), “maximum”)

if (Test-Path ‘HKLM:SoftwareDellWarranty’ -erroraction silentlycontinue) {
    #”Registry key HKLM:SoftwareDellWarranty already exists.”
} else {
    md HKLM:SoftwareDellWarranty
}

if (Get-ItemProperty -Name “WarrantyExpiry” -path ‘HKLM:SoftwareDellWarranty’ -erroraction silentlycontinue) {
    #”Registry key HKLM:SoftwareDellWarrantyWarrantyExpiry already exists.”
} else {
    New-ItemProperty “HKLM:SoftwareDellWarranty” -Name “WarrantyExpiry” -Value $maxdate.toshortdatestring() -PropertyType “String”
}

One thought on “Powershell script to query Dell website for Warranty End Date”

  1. Thanks for posting, very helpful. This is very nice because Dell is consantly changing their site and the text scraping methods don’t work for very long, not to mention the URLs changing.

Leave a Reply