Updated Dell Warranty Information Script

By , February 14, 2012 6:09 pm

Recently, Dell made some changes to their support website that broke the Dell Warranty Information Script. After investigating the changes, I determined that the new warranty information URL does not accept the service tag as a URL parameter, or at least it doesn’t appear to. Instead, the service tag is retrieved from a cookie that is generated when you enter the tag on this page. Good grief.

Scripting the cookies and passing them is probably possible, but I felt it was stretching the solution too far, so I adapted the script to use the undocumented SOAP web service instead. The script is below.

There are several things that I dislike about Dell’s AssetService web service:

  1. It’s completely undocumented, and no one really knows what the guid and applicationName parameters are meant to do. I haven’t found anything indicating that it’s even a production service.
  2. The descriptions returned for each entitlement (warranty record) aren’t as well formatted.
  3. Sometimes, it doesn’t return the list of entitlements, so the script needs to be run again until it does.

Alas, this is going to have to work for now until a better solution presents itself. If you’ve found a better solution, please share in the comments.

'=====================================================================
'    Dell Warranty Grabber
'    Author:     Matthew Boyd (iboyd.net)
'    Date:        2/14/2012
'
'    This is  an example of how to query the Dell asset information
'    web service for warranty information and parse the XML result.
'    values are then written to the registry of the local
'    computer. FYI: Sometimes, the web service doesn't return any
'    entitlements (warranties), but then returns them after
'    subsequent requests.
'
'    Usage:    cscript.exe DellWarrantyGrabber.vbs
'
'    Note: This must be run under an account with admin rights.
'    This script is provided AS IS with no support or warranties.
'    Use at your own risk!
'=====================================================================
Option Explicit
Dim SoapRequest
Dim url, regkey, svctag
Dim warrantyRows, warrantyCols
Dim objShell, objXML, objWMI, objHTTP, NodeList
Dim i, result

SoapRequest = "<?xml version=""1.0"" encoding=""utf-8""?> <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""> <soap:Body> <GetAssetInformation xmlns=""http://support.dell.com/JigsawWebServices/""> <guid>11111111-1111-1111-1111-111111111111</guid> <applicationName>Warranty Information Lookup</applicationName> <serviceTags>!SERVICETAG!</serviceTags> </GetAssetInformation> </soap:Body></soap:Envelope>"

url = "http://xserv.dell.com/jigsawwebservices/AssetService.asmx"
regkey = "HKEY_LOCAL_MACHINE\Software\DellWarrantyInfo"
set objShell = WScript.CreateObject("WScript.Shell")
set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

If InStr(UCase(objWMI.ExecQuery("Select Manufacturer From Win32_ComputerSystem").ItemIndex(0).Manufacturer), "DELL") = 0 then Err.Raise 2, "This is not a Dell dude!", "No Service Tag"

svctag = Trim(objWMI.ExecQuery  ("Select SerialNumber from Win32_BIOS").ItemIndex(0).SerialNumber)

wscript.echo "Service Tag: " & svctag
SoapRequest = Replace(SoapRequest, "!SERVICETAG!", svctag)
result = objShell.Run("reg.exe delete '" & regkey & "' /f", true)
If not result = 0 then Err.Raise result, "Unable to delete registry key!", "Code " & result

result = objShell.Run("reg.exe create '" & regkey & "' /ve", true)
If not result = 0 then Err.Raise result, "Unable to delete registry key!", "Code " & result

Set objHTTP = CreateObject("Msxml2.XMLHTTP")
objHTTP.open "POST", URL, false
objHTTP.setRequestHeader "Content-Type", "text/xml"
objHTTP.setRequestHeader "SOAPAction", "http://support.dell.com/JigsawWebServices/GetAssetInformation"
objHTTP.send SoapRequest

result = objHTTP.responseText

Set objXML = CreateObject ("Msxml2.DOMDocument")
objXML.LoadXml result

If not objXML.SelectSinglenode ("//faultstring") is nothing then
    Err.Raise 1,  "Error:" & objXML.SelectSingleNode("//faultcode").text, Trim(objXML.SelectSingleNode("//faultstring").text)
End If
wscript.echo objXML.xml
Set NodeList = objXML.SelectNodes("//Asset/Entitlements/EntitlementData")
 wscript.echo NodeList.length & " results returned: "

For i = 0 to NodeList.length - 1
set warrantyCols = NodeList.item(i)
wscript.echo Mid(warrantyCols.SelectSingleNode("ServiceLevelDescription").text,4)

objShell.regWrite regkey & "\" & i & "\", ""
objShell.regWrite regkey & "\" & i & "\Description", Mid(warrantyCols.SelectSingleNode("ServiceLevelDescription").text, 4)
objShell.regWrite regkey & "\" & i & "\Provider", warrantyCols.SelectSingleNode("Provider").text
objShell.regWrite regkey & "\" & i & "\Entitlement Type", warrantyCols.SelectSingleNode("EntitlementType").text
objShell.regWrite regkey & "\" & i & "\Start Date", Left(warrantyCols.SelectSingleNode("StartDate").text, 10)
objShell.regWrite regkey & "\" & i & "\End Date", Left(warrantyCols.SelectSingleNode("EndDate").text, 10)
objShell.regWrite regkey & "\" & i & "\Days Left", warrantyCols.SelectSingleNode("DaysLeft").text

Next

44 Responses to “Updated Dell Warranty Information Script”

  1. [...] Important: Due to changes to Dell’s website, the script below no longer works. An updated script is available on this page. [...]

  2. Bart says:

    http://www.dell.com/support/troubleshooting/us/en/555/index?c=us&l=en&s=biz&cs=555&servicetag= works…

    I haven’t really looked at your script to determine if this is actually helpful, but based on your comment “I determined that the new warranty information URL does not accept the service tag as a URL parameter” I thought I’d mention it.

  3. Suresh says:

    Hi Boyd and Bart,

    Used the above (Boyd) script, but this will bring the dell warranty info of the current system from the registry. but how can I eun this script for to querying mass level of service tag as we have ran the qurey before.
    please need help and thanks in advance.

    Regards,
    Suresh

  4. bback says:

    Hi Boyd,
    nice vbs script.If you prefer graphical interface I recommend this tool
    http://sourceforge.net/projects/dellwt/
    -Import service tags from text file
    -Export to csv

  5. Greg says:

    Thanks so much for this code. I wasn’t looking forward to doing yearly inventory and having to send a list of service tags to Dell to get the ship date for each one. I think I found a way to improve the reliability, though. After noticing that the Warranty Info Plugin for the SCCM Client Center is always able to return the warranty information, I took a look at the source code at http://warrantyplugin.codeplex.com/. As it turns out, only a few basic URL changes are needed. Every instance of “http://support.dell.com/JigsawWebServices” should be changed to “http://support.dell.com/WebServices”. The URL “http://xserv.dell.com/jigsawwebservices/AssetService.asmx” should also be changed to “http://xserv.dell.com/services/assetservice.asmx”. After making those changes, I’ve yet to see a failure on returning the warranty information. Thanks again!

    • Eric says:

      You rock ! I was trying for hours to solve this, and it kept answering “An exception occured”… Then, after changing the URLs as you mentionned, it works like a charm. Thanks for sharing this.

  6. Chris says:

    Boyd, thank you for this script! It is answering a big issue we had of not being able to follow the warranties of our servers.

    I did run into a problem though. I had removed all of the registry and WMI calls that get the svctag and am manually setting it in the script for now (it will become part of a much larger script in the future). When it runs against an older 2950 with several warranty extensions it will bomb out and show:
    “Microsoft VBScript runtime error: Object required: ‘SelectSinglenode(…)'”.

    The line that it is referring to is:
    “wscript.echo Mid(warrantyCols.SelectSingleNode(“ServiceLevelDescription”).text,4)”.

    After cleaning up the raw response it looks like it is throwing up on this line:

    To remedy i put in an if around the output section:
    if not warrantyCols.SelectSingleNode(“ServiceLevelDescription”) is nothing then
    do output
    end if

    I don’t know why Dell put that in the output or what it even means but wanted to let others know the workaround in case they see this issue.

    Bart, thank you for the new URL! I really wish I could utilize this in our monitoring system but alas it will not allow the svctag to be dynamically added to the URL.

  7. Edgeman says:

    As of today I can’t resolve xserv.dell.com :(

  8. Jack says:

    We have been using a vbs script to get Dell Warranty information and output it as part of our computer desktop BGInfo. The script used MSXML instead of ServerMSXML and now will not work after MS patched the security issue. I am attempting to use this script to get the same information but I get an error related to xml version and some of the SOAP command lines as of today 3/20/2012. I am vbs illiterate and really need some guidance in getting this resolved for my end-users (approx. 250 and growing). I can post the original script I found if necessary.

    • Boyd says:

      Hmm… I use the MSXML object in my scripts and it seems to be working on my patched Win7 64-bit box. What error message are you getting? If you can paste the vbscript into Pastebin and share the link, I’ll try to take a look.

    • Dustin says:

      If you are getting an error about msxml3.dll accessed denied it’s because of a GPO setting. Make sure the “access data sources across domains” is set to enabled under “Computer configuration\windows components\internet explorer\internet control panel\security page\internet zone”

  9. Bill says:

    I keep getting the following error:

    C:\Dell-Warranty-1.vbs(1, 1) Microsoft
    VBScript compilation error: Invalid character

    • Bill says:

      I have even tried changing the web site as Greg suggested. Thanks

    • Boyd says:

      That sounds like a copy-paste error. Can you make sure you didn’t miss the first character (an apostrophe) in the script? Also, when you hover over the script you should see a toolbar at the top right that allows you to view the plain-text source code.

      As others have indicated, due to changes that Dell has made the script may not be able to retrieve warranty information, even if it runs.

      • Bill says:

        Here is the code:

        Option Explicit

        Dim SoapRequest

        Dim url, regkey, svctag

        Dim warrantyRows, warrantyCols

        Dim objShell, objXML, objWMI, objHTTP, NodeList

        Dim i, result

        SoapRequest = ” 11111111-1111-1111-1111-111111111111 Warranty Information Lookup !SERVICETAG! ”

        url = “http://xserv.dell.com/jigsawwebservices/AssetService.asmx”

        regkey = “HKEY_LOCAL_MACHINE\Software\DellWarrantyInfo”

        set objShell = WScript.CreateObject(“WScript.Shell”)

        set objWMI = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2″)

        If InStr(UCase(objWMI.ExecQuery(“Select Manufacturer From Win32_ComputerSystem”).ItemIndex(0).Manufacturer), “DELL”) = 0 then Err.Raise 2, “This is not a Dell dude!”, “No Service Tag”

        svctag = Trim(objWMI.ExecQuery (“Select SerialNumber from Win32_BIOS”).ItemIndex(0).SerialNumber)

        wscript.echo “Service Tag: ” & svctag

        SoapRequest = Replace(SoapRequest, “!SERVICETAG!”, svctag)

        result = objShell.Run(“reg.exe delete ‘” & regkey & “‘ /f”, true)

        If not result = 0 then Err.Raise result, “Unable to delete registry key!”, “Code ” & result

        result = objShell.Run(“reg.exe create ‘” & regkey & “‘ /ve”, true)

        If not result = 0 then Err.Raise result, “Unable to delete registry key!”, “Code ” & result

        Set objHTTP = CreateObject(“Msxml2.XMLHTTP”)

        objHTTP.open “POST”, URL, false

        objHTTP.setRequestHeader “Content-Type”, “text/xml”

        objHTTP.setRequestHeader “SOAPAction”, “http://support.dell.com/JigsawWebServices/GetAssetInformation”

        objHTTP.send SoapRequest

        result = objHTTP.responseText

        Set objXML = CreateObject (“Msxml2.DOMDocument”)

        objXML.LoadXml result

        If not objXML.SelectSinglenode (“//faultstring”) is nothing then

        Err.Raise 1, “Error:” & objXML.SelectSingleNode(“//faultcode”).text, Trim(objXML.SelectSingleNode(“//faultstring”).text)

        End If

        wscript.echo objXML.xml

        Set NodeList = objXML.SelectNodes(“//Asset/Entitlements/EntitlementData”)

        wscript.echo NodeList.length & ” results returned: ”

        For i = 0 to NodeList.length – 1

        set warrantyCols = NodeList.item(i)

        wscript.echo Mid(warrantyCols.SelectSingleNode(“ServiceLevelDescription”).text,4)

        objShell.regWrite regkey & “\” & i & “\”, “”

        objShell.regWrite regkey & “\” & i & “\Description”, Mid(warrantyCols.SelectSingleNode(“ServiceLevelDescription”).text, 4)

        objShell.regWrite regkey & “\” & i & “\Provider”, warrantyCols.SelectSingleNode(“Provider”).text

        objShell.regWrite regkey & “\” & i & “\Entitlement Type”, warrantyCols.SelectSingleNode(“EntitlementType”).text

        objShell.regWrite regkey & “\” & i & “\Start Date”, Left(warrantyCols.SelectSingleNode(“StartDate”).text, 10)

        objShell.regWrite regkey & “\” & i & “\End Date”, Left(warrantyCols.SelectSingleNode(“EndDate”).text, 10)

        objShell.regWrite regkey & “\” & i & “\Days Left”, warrantyCols.SelectSingleNode(“DaysLeft”).text

        Next

  10. Bill says:

    http://www.dell.com/support/troubleshooting/us/en/555/Index?c=us&l=en&s=biz&cs=555&serviceTag=65KFMN1&t=warranty

    This is not my real service tag, but if you put a real service tag in its place it will take you to the warranty page.

  11. Bill says:

    Copy and paste the link to notepad and the copy to a web browser

  12. [...] any documentation from Dell about this service outside the inline documentation, and according to one comment it can have stability issues, but it is a lot better than scraping HTML [...]

  13. Vianney says:

    Hello from France Mister Boyd and thank you for the script.

    AssetService.asmx seems to be here now :
    http://xserv.dell.com/services/AssetService.asmx

    You can see it here : http://xserv.dell.com/services/assetservice.asmx?WSDL

    Have a nice day

  14. Figo says:

    Because i just wasnt satisfied with all the different ways of warranty checks i wrote a little function. feel free to integrate it into your automation…

    It would be nice to get some feedback, especially since im not the PS Guru and if you see ways to improve the function/code etc… pls let me know :)

    One thing i thought about was to generate the cookie on the fly without the need to copy it from a pseudo request. (i might change if i feel i have to kill some time(if its even possible))

    Function Get-DellWarrantyContracts() {
    param([String]$ServiceTag)

    #Sample Cookie
    #$cookie = “ASP.NET_SessionId=2ey52zsdjjmdcslm3fvyxc3c; path=/; HttpOnly,OLRProduct=OLRProduct=$ServiceTag|; domain=dell.com; expires=Thu, 22-Aug-2013 14:01:18 GMT; path=/,lwp=c=in&l=en&cs=inbsd1; domain=.dell.com; path=/”
    $BaseURL = “http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?c=in&cs=inbsd1&l=en&s=bsd&ServiceTag=$ServiceTag&~tab=1″
    $WarrantyURL = “http://www.dell.com/support/troubleshooting/in/en/inbsd1/TroubleShooting/Display_Warranty_Tab?name=TroubleShooting_WarrantyTab”

    $REGEXShipping = [Regex]‘(?s)\s*Country:\s*\s*\s*(?[^<]+)\s*.*\s*Ship Date:\s*\s*\s*(?(?[0-9]{2})-(?[0-9]{2})-(?[0-9]{4}))\s*’
    $REGEXGetContractTableBody = [Regex]‘(?s)(?.*)’
    $REGEXGetContractRow = [Regex]‘(?s)]*>\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*’

    $DellWarrantySite = New-Object System.Net.WebClient

    $DellWarrantySite.DownloadString($BaseURL) | Out-Null
    $cookie = $DellWarrantySite.ResponseHeaders["Set-Cookie"]
    $DellWarrantySite.Headers.add(“Cookie”,$cookie)
    $HTMLResponse = ($DellWarrantySite.DownloadString($WarrantyURL) | Out-String).Replace(“`n”,””)

    If( $HTMLResponse -match $REGEXShipping ) {

    $Warranty = New-Object System.Object
    $Warranty | Add-Member -MemberType NoteProperty -Name ServiceTag -Value $ServiceTag
    $Warranty | Add-Member -MemberType NoteProperty -Name Country -Value $Matches["Country"]
    $Warranty | Add-Member -MemberType NoteProperty -Name ShipDate -Value $Matches["ShipDate"]

    # $ShipDateDay = $Matches["ShipDateDay"]
    # $ShipDateMonth = $Matches["ShipDateMonth"]
    # $ShipDateYear = $Matches["ShipDateYear"]

    $ContractList = @()
    If( $HTMLResponse -match $REGEXGetContractTableBody ) {
    (Select-String -InputObject $Matches["TableBody"] -Pattern $REGEXGetContractRow -AllMatches).matches | %{

    $Contract = New-Object System.Object
    $Contract | Add-Member -MemberType NoteProperty -Name ContractDescription -Value $_.Groups[1].Value
    $Contract | Add-Member -MemberType NoteProperty -Name Provider -Value $_.Groups[2].Value
    $Contract | Add-Member -MemberType NoteProperty -Name StartDate -Value $_.Groups[3].Value
    $Contract | Add-Member -MemberType NoteProperty -Name EndDate -Value $_.Groups[4].Value
    $Contract | Add-Member -MemberType NoteProperty -Name DaysLeft -Value $_.Groups[5].Value

    If( $([datetime]$_.Groups[3].Value) -gt $(date) ) { $ContractState = “Future” }
    ElseIf( $([int]$_.Groups[5].Value) -eq 0 ){ $ContractState = “Expired” }
    Else{ $ContractState = “Active” }
    $Contract | Add-Member -MemberType NoteProperty -Name Status -Value $ContractState

    $ContractList += $Contract
    }
    }
    $Warranty | Add-Member -MemberType NoteProperty -Name Contracts -Value $ContractList
    }
    return $Warranty
    }

    Greetings
    Figo

    • Figo says:

      btw: it returns a powershell object similar to the xml object of dells service but with all the information…

    • figo says:

      just realized that html tags were filtered out by the forum so the regexes are not working…
      in case somebody wants the working function, speak out ;)

  15. Matt says:

    When I call the GetAssetInformation service it never has the provider or ServiceLevel* fields populated – all I get is the start and end date and the fact it’s expired – can’t see that this is much use as I need to know the type of warranty entitlement – assuming Dell has more than one type – like hp etc do.

    Any ideas?! :-(

    • figo says:

      i wrote a function that parses the website and combined it with the soap request.
      Luckily they list the contracts in the same order. made it a little easier…

      the script works perfectly for me.
      BUT: there is next to no error catching…
      It reads the service tags from a sql table gets the contract information and writes it into another table…
      (the forum filters tags so it will not work when copied from here…)

      $WebQueryEnabled = $true
      $Vendor = “Dell”

      $SQLServer =
      $SQLDBName =
      $SugarContractTable =
      $SugarServiceTagView =
      $SQLGetTagsQuery = “SELECT s.service_tag, s.name FROM $SugarServiceTagView AS s WHERE s.Manufacturer = ‘$Vendor'”

      Function Query-DB {
      param([string]$SQLServer,[string]$SQLDBname,[string]$SQLQuery)

      $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
      $SqlConnection.ConnectionString = “Server = $SQLServer; Database = $SQLDBName; Integrated Security = True”

      $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
      $SqlCmd.CommandText = $SqlQuery
      $SqlCmd.Connection = $SqlConnection

      $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
      $SqlAdapter.SelectCommand = $SqlCmd

      $DataSet = New-Object System.Data.DataSet
      $SqlAdapter.Fill($DataSet) | Out-Null

      $SqlConnection.Close()

      return ,$Dataset.Tables[0]
      }
      Function Get-DellSOAPContracts{
      Param([String]$ServiceTag)
      Try{
      $AssetService = New-WebServiceProxy -Uri “http://xserv.dell.com/services/AssetService.asmx?WSDL”
      $ApplicationName = “AssetService”
      $Guid = [Guid]::NewGuid()
      $Asset = ($AssetService.GetAssetInformation($Guid,$ApplicationName,$ServiceTag)).SyncRoot[0]
      }
      Catch{
      Write-Host $($_.Exception.Message)
      }

      $Warranty = New-Object System.Object
      $Warranty | Add-Member -MemberType NoteProperty -Name ServiceTag -Value $Asset.AssetHeaderData.ServiceTag
      $Warranty | Add-Member -MemberType NoteProperty -Name SystemID -Value $Asset.AssetHeaderData.SystemID
      $Warranty | Add-Member -MemberType NoteProperty -Name SystemType -Value $Asset.AssetHeaderData.SystemType
      $Warranty | Add-Member -MemberType NoteProperty -Name SystemModel -Value $Asset.AssetHeaderData.SystemModel
      $Warranty | Add-Member -MemberType NoteProperty -Name Region -Value $Asset.AssetHeaderData.Region
      $Warranty | Add-Member -MemberType NoteProperty -Name SystemShipDate -Value $Asset.AssetHeaderData.SystemShipDate.Date

      $ContractList = @()

      Foreach($Entitlement in ($Asset.get_Entitlements())) {

      $Contract = New-Object System.Object

      If($Asset.AssetHeaderData.ServiceTag -eq $null) { $Asset.AssetHeaderData.set_ServiceTag(“”) }
      If($Asset.AssetHeaderData.SystemID -eq $null) { $Asset.AssetHeaderData.set_SystemID(“”) }
      If($Asset.AssetHeaderData.SystemType -eq $null) { $Asset.AssetHeaderData.set_SystemType(“”) }
      If($Asset.AssetHeaderData.SystemModel -eq $null) { $Asset.AssetHeaderData.set_SystemModel(“”) }
      If($Asset.AssetHeaderData.Region -eq $null) { $Asset.AssetHeaderData.set_Region(“”) }
      If($Asset.AssetHeaderData.SystemShipDate.Date -eq $null){ $Asset.AssetHeaderData.set_SystemShipDate(“”) }

      If($Entitlement.Provider -eq $null) { $Entitlement.set_Provider(“”) }
      If($Entitlement.ServiceLevelCode -eq $null) { $Entitlement.set_ServiceLevelCode(“”) }
      If($Entitlement.ServiceLevelDescription -eq $null) { $Entitlement.set_ServiceLevelDescription(“”) }
      If($Entitlement.StartDate -eq $null) { $Entitlement.set_StartDate(“”) }
      If($Entitlement.EndDate -eq $null) { $Entitlement.set_EndDate(“”) }
      If($Entitlement.DaysLeft -eq $null) { $Entitlement.set_DaysLeft(“0″) }
      If($Entitlement.EntitlementType -eq $null) { $Entitlement.set_EntitlementType(“”) }

      $Contract = New-Object System.Object
      $Contract | Add-Member -MemberType NoteProperty -Name ServiceTag -Value $Asset.AssetHeaderData.ServiceTag
      $Contract | Add-Member -MemberType NoteProperty -Name SystemID -Value $Asset.AssetHeaderData.SystemID
      $Contract | Add-Member -MemberType NoteProperty -Name SystemType -Value $Asset.AssetHeaderData.SystemType
      $Contract | Add-Member -MemberType NoteProperty -Name SystemModel -Value $Asset.AssetHeaderData.SystemModel
      $Contract | Add-Member -MemberType NoteProperty -Name Region -Value $Asset.AssetHeaderData.Region
      $Contract | Add-Member -MemberType NoteProperty -Name SystemShipDate -Value $Asset.AssetHeaderData.SystemShipDate.Date

      $Contract | Add-Member -MemberType NoteProperty -Name Provider -Value $Entitlement.Provider
      $Contract | Add-Member -MemberType NoteProperty -Name ServiceLevelCode -Value $Entitlement.ServiceLevelCode
      $Contract | Add-Member -MemberType NoteProperty -Name ServiceLevelDescription -Value $Entitlement.ServiceLevelDescription
      $Contract | Add-Member -MemberType NoteProperty -Name StartDate -Value $Entitlement.StartDate
      $Contract | Add-Member -MemberType NoteProperty -Name EndDate -Value $Entitlement.EndDate
      $Contract | Add-Member -MemberType NoteProperty -Name DaysLeft -Value $Entitlement.DaysLeft
      $Contract | Add-Member -MemberType NoteProperty -Name EntitlementType -Value $Entitlement.EntitlementType

      $ContractList += $Contract
      }
      $Warranty | Add-Member -MemberType NoteProperty -Name Contracts -Value $ContractList

      return $Warranty
      }
      Function Get-DellWebContracts {
      param([String]$ServiceTag)

      #Sample Cookie
      #$cookie = “ASP.NET_SessionId=2ey52zsdjjmdcslm3fvyxc3c; path=/; HttpOnly,OLRProduct=OLRProduct=$ServiceTag|; domain=dell.com; expires=Thu, 22-Aug-2013 14:01:18 GMT; path=/,lwp=c=in&l=en&cs=inbsd1; domain=.dell.com; path=/”
      #$BaseURL = “http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?c=in&cs=inbsd1&l=en&s=bsd&ServiceTag=$([string]$ServiceTag)&~tab=1″
      $BaseURL = “http://www.dell.com/support/troubleshooting/in/en/inbsd1/Index?c=in&s=bsd&cs=inbsd1&l=en&t=warranty&servicetag=$([String]$ServiceTag)”
      $WarrantyURL = “http://www.dell.com/support/troubleshooting/in/en/inbsd1/TroubleShooting/Display_Warranty_Tab?name=TroubleShooting_WarrantyTab”

      $REGEXShipping = [Regex]‘(?s)\s*Country:\s*\s*\s*(?[^<]+)\s*.*\s*Ship Date:\s*\s*\s*(?(?[0-9]{2})-(?[0-9]{2})-(?[0-9]{4}))\s*’
      $REGEXGetContractTableBody = [Regex]‘(?s)(?.*)’
      $REGEXGetContractRow = [Regex]‘(?s)]*>\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*\s*(?[^>]+)\s*\s*’

      $DellWarrantySite = New-Object System.Net.WebClient
      $DellWarrantySite.Headers.Add(“User-Agent”, “Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12″)
      $DellWarrantySite.Headers.Add(“Accept”, “*/*”)
      $DellWarrantySite.Headers.Add(“Accept-Language”, “en-US,en;q=0.5″)
      $DellWarrantySite.Headers.Add(“Accept-Charset”, “ISO-8859-1,utf-8;q=0.7,*;q=0.7″)

      $DellWarrantySite.DownloadString($BaseURL) | Out-Null
      $cookie = $DellWarrantySite.ResponseHeaders["Set-Cookie"]

      If( $cookie -notmatch $ServiceTag ){ return $null }
      Else {
      $DellWarrantySite.Headers.add(“Cookie”,$cookie)
      $HTMLResponse = ($DellWarrantySite.DownloadString($WarrantyURL) | Out-String).Replace(“`n”,””)

      If( $HTMLResponse -match $REGEXShipping ) {

      $Warranty = New-Object System.Object
      $Warranty | Add-Member -MemberType NoteProperty -Name ServiceTag -Value $ServiceTag
      $Warranty | Add-Member -MemberType NoteProperty -Name Country -Value $Matches["Country"]
      $Warranty | Add-Member -MemberType NoteProperty -Name ShipDate -Value $([DateTime]::ParseExact($Matches["ShipDate"], “dd’-‘MM’-‘yyyy”, $null))

      $ContractList = @()
      If( $HTMLResponse -match $REGEXGetContractTableBody ) {
      (Select-String -InputObject $Matches["TableBody"] -Pattern $REGEXGetContractRow -AllMatches).matches | %{

      $Contract = New-Object System.Object
      $Contract | Add-Member -MemberType NoteProperty -Name ContractDescription -Value $_.Groups[1].Value
      $Contract | Add-Member -MemberType NoteProperty -Name Provider -Value $_.Groups[2].Value
      $Contract | Add-Member -MemberType NoteProperty -Name StartDate -Value $_.Groups[3].Value
      $Contract | Add-Member -MemberType NoteProperty -Name EndDate -Value $_.Groups[4].Value
      $Contract | Add-Member -MemberType NoteProperty -Name DaysLeft -Value $_.Groups[5].Value

      $ContractList += $Contract
      }
      }
      $Warranty | Add-Member -MemberType NoteProperty -Name Contracts -Value $ContractList
      }
      return $Warranty
      }
      }
      Function Get-DellContractInformation {
      param([String]$ServiceTag,[Bool]$WithWebQuery)

      $SOAPContracts = Get-DellSOAPContracts $ServiceTag

      If( $WithWebQuery ) {
      $WebContracts = Get-DellWebContracts $ServiceTag

      $count = 0
      Foreach( $soapcontract in $SOAPContracts.Contracts ) {
      $soapcontract.ServiceLevelDescription = $WebContracts.Contracts[$count].ContractDescription
      $count++
      }
      }
      return $SOAPContracts
      }

      $ServiceTagList = Query-DB -SQLServer $SQLServer -SQLDBname $SQLDBname -SQLQuery $SQLGetTagsQuery

      Foreach( $entry in $ServiceTagList ) {

      $temp = Get-DellContractInformation -ServiceTag $entry.service_tag -WithWebQuery $WebQueryEnabled

      Foreach( $Entitlement in $temp.Contracts ) {
      $SQLCheckEntitlement = “SELECT * FROM $SugarContractTable AS s WHERE s.ServiceTag = ‘$([string]$temp.ServiceTag)’ AND s.StartDate = ‘$([string]$Entitlement.StartDate)’ AND s.EndDate = ‘$([string]$Entitlement.EndDate)’ AND s.ServiceLevelDescription = ‘$([string]$Entitlement.ServiceLevelDescription)'”
      $EntitlementTable = Query-DB -SQLServer $SQLServer -SQLDBname $SQLDBName -SQLQuery $SQLCheckEntitlement

      If( $EntitlementTable.Rows.Count -lt 1 ) {

      $SQLInsertEntitlement = @”
      INSERT INTO $SugarContractTable Values(
      ‘$($Entitlement.ServiceTag)’,
      ‘$($Entitlement.SystemID)’,
      ‘$($Entitlement.SystemType)’,
      ‘$($Entitlement.SystemModel)’,
      ‘$($Entitlement.Region)’,
      ‘$($Entitlement.SystemShipDate)’,
      ‘$($Entitlement.ServiceLevelCode)’,
      ‘$($Entitlement.ServiceLevelDescription)’,
      ‘$($Entitlement.Provider)’,
      ‘$($Entitlement.StartDate)’,
      ‘$($Entitlement.EndDate)’,
      ‘$($Entitlement.EntitlementType)’,
      GetDate(),
      ‘$vendor’)
      “@
      Query-DB -SQLServer $SQLServer -SQLDBname $SQLDBName -SQLQuery $SQLInsertEntitlement
      }
      }
      }

  16. Jane says:

    Looks like more changes to Dell’s warranty site. New URL is
    http://www.dell.com/support/troubleshooting/us/en/555/Servicetag/

    subsitute the with your Dell Server’s tag number.

  17. Robert says:

    How would you access other information that is stored in the tabs like manuals & documents, system configuration, parts & upgrades.

  18. Ajinkya says:

    Hi,
    I’m looking for a warranty script for HP.. As per i know they have changed their warranty url. https://h20565.www2.hp.com/portal/site/hpsc/public/wc/home/?ac.admitted=1383025690797.876444892.492883150 . So can you tell me how can i grab warranty information from this url.. Anything in PHP or VBScript or any suggestion would be appreciated

Leave a Reply

Panorama Theme by Themocracy