none
Get Lenovo Warranty info automatically

    Question

  • Hey all so I have a sript that pulls a lot of info and throws it in a DB. Till recently I was also able to pull the warranty end date of Lenovo machines.

    I used this:

    $URL = "https://services.lenovo.com/ibapp/il/WarrantyStatus.jsp?type=$($Win32.Model)&serial=$($BIOS.SerialNumber)"
    $WebRequestResult = Invoke-WebRequest -Uri $URL
    $TDTagNames = $WebRequestResult.ParsedHtml.getElementsByTagName("TD")
    foreach ($TDTagName in $TDTagNames) {
        if (($TDTagName.innerHTML -match "\d{4}-\d{2}-\d{2}") -and ($TDTagName.width -eq 120)) {
            $Warranty = $TDTagName.innerHTML
            break
        }
    }

    It looks like now that URL does not work anymore for some reason. So my question is does anyone know of an automated way to get this info? Is it possible to take a web page and insert info in a text box, submit that, and filter the return info for the date? I've been trying this on this webpage with no luck: http://support.lenovo.com/us/en/warrantylookup

    Thanks for any help!! From what I've seen the method I was using was a standard way of doing it but it looks like Lenovo is not supporting it anymore. Thanks!


    Thursday, July 23, 2015 5:31 PM

Answers

  • Here you go this is working 

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
    $form = $test.forms[4]
    $form.Fields["serialCode"]="MJCTV84"
    $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
    $answer.AllElements|where class -eq "reset"|Select -First 1 -ExpandProperty innerText

    Now this come out whit all the info you need

    Hope this help


    Thursday, July 23, 2015 6:40 PM
  • It looks like Lenovo has has changed something: You'll need to replace forms[4] to forms[0] to get this to work.
    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
    $form = $test.forms[0]
    $serial = 'MJNECHL'
    $form.Fields["serialCode"]="$($serial)"
    $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
    $a = $answer.ParsedHtml.getElementById("warranty_result_div").outerText
    $a.Substring(39,10)
    Thanks I figured I would update this in case it helps anyone. I saw someone had done this from a comment on this post: http://www.scconfigmgr.com/2015/03/21/get-lenovo-warranty-information-with-powershell/
    • Marked as answer by Cody_Horton Thursday, September 24, 2015 1:12 PM
    Thursday, September 24, 2015 1:12 PM

All replies

  • I think I'm on to something but would love some help

    $ie = new-object -com "InternetExplorer.Application"
    $ie.navigate("http://support.lenovo.com/us/en/warrantylookup")
    $ie.visible = $true
    while($ie.busy) {sleep 1}
    
    $doc = $ie.document
    $doc.getElementById("serialCode").value="MJCTV84"
    $doc.getElementById("warrantySubmit").click

    Thursday, July 23, 2015 5:41 PM
  • Ask in Lenovo forum for the location of the web service for the warrantees.  You should be able to get all warrantees in XML for a registered customer.

    Use: New-WebServiceProxy to extract the information.


    \_(ツ)_/

    Thursday, July 23, 2015 5:47 PM
    Moderator
  • Here is the batch lookup site: https://csp.lenovo.com/ibapp/il/WarrantyLookupBatch.jsp


    \_(ツ)_/

    Thursday, July 23, 2015 5:48 PM
    Moderator
  • Okay thanks JRV I'll look into that. 
    Thursday, July 23, 2015 5:49 PM
  • Here is the batch lookup site: https://csp.lenovo.com/ibapp/il/WarrantyLookupBatch.jsp


    \_(ツ)_/

    Thanks JRV but how would I integrate this into a script. I want it to all be automated so there is no human interaction or error.
    Thursday, July 23, 2015 5:54 PM
  • here is how to do it with the web query:

    Just supply model and serialnumber

    $URL = "https://services.lenovo.com/ibapp/il/WarrantyStatus.jsp?type=$($Model)&serial=$($SerialNumber)"


    \_(ツ)_/


    Thursday, July 23, 2015 5:55 PM
    Moderator
  • You could do something with Invoke-WebRequest 

    a quick example this would get the info from the vendore you populate the form and you post it back you should get the answer in the $resp so just have to filter it down.

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup
    $form = $test.Forms[4].fields
    $Form.fields["serialCode"]="yourserialcode"
    $resp = Invoke-WebRequest -uri ("http://support.lenovo.com/us/en/warrantylookup" + $form.Action) -Method POST -Body $form.Fields

    PS: JRV am prety sure you can fix my code to make it a lot sexier :)

    Thursday, July 23, 2015 5:56 PM
  • here is how to do it with the web query:

    Just supply model and serialnumber

    $URL = "https://services.lenovo.com/ibapp/il/WarrantyStatus.jsp?type=$($Model)&serial=$($SerialNumber)"


    \_(ツ)_/


    Hey JRV this is the script I was orignaly using but it no longer works. It gives you a 500 internal server error. Try using this to test it: https://services.lenovo.com/ibapp/il/WarrantyStatus.jsp?type=7484WJU&serial=MJCTV84
    Thursday, July 23, 2015 6:04 PM
  • You could do something with Invoke-WebRequest 

    a quick example this would get the info from the vendore you populate the form and you post it back you should get the answer in the $resp so just have to filter it down.

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup
    $form = $test.Forms[4].fields
    $Form.fields["serialCode"]="yourserialcode"
    $resp = Invoke-WebRequest -uri ("http://support.lenovo.com/us/en/warrantylookup" + $form.Action) -Method POST -Body $form.Fields

    PS: JRV am prety sure you can fix my code to make it a lot sexier :)

    $url= "https://services.lenovo.com/ibapp/il/WarrantyStatus.jsp?type=$Mode)&serial=$SerialNumber"

    Invoke-WebRequest $url

    Give me a valid type and serial number and I will give yuo a working example.  I havenolenoveboxes.


    \_(ツ)_/


    Thursday, July 23, 2015 6:05 PM
    Moderator
  • You could do something with Invoke-WebRequest 

    a quick example this would get the info from the vendore you populate the form and you post it back you should get the answer in the $resp so just have to filter it down.

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup
    $form = $test.Forms[4].fields
    $Form.fields["serialCode"]="yourserialcode"
    $resp = Invoke-WebRequest -uri ("http://support.lenovo.com/us/en/warrantylookup" + $form.Action) -Method POST -Body $form.Fields

    PS: JRV am prety sure you can fix my code to make it a lot sexier :)

    $url= "https://services.lenovo.com/ibapp/il/WarrantyStatus.jsp?type=$Mode)&serial=$SerialNumber"

    Invoke-WebRequest $url

    Give me a valid type and serial number and I will give yuo a working example.  I havenolenoveboxes.


    \_(ツ)_/


    Try this type: 7484WJU

    Serial: MJCTV84

    Thursday, July 23, 2015 6:08 PM
  • Use this one MJCTV84 provided by the Original poster
    Thursday, July 23, 2015 6:09 PM
  • You can also see the last comment on that page: http://www.scconfigmgr.com/2015/03/21/get-lenovo-warranty-information-with-powershell/ by Casey Robertson that they are getting the same error. The site seems to not have worked starting this month.
    Thursday, July 23, 2015 6:25 PM
  • Lenovo has changed the site too block automation.  They don't want it.  They have added the batch query.  Just upload a spreadsheet occasionally and get all warranty info in one batch.

    Your purchasing department needs to add an admins email to the warranty notification alerts.


    \_(ツ)_/

    Thursday, July 23, 2015 6:38 PM
    Moderator
  • Here you go this is working 

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
    $form = $test.forms[4]
    $form.Fields["serialCode"]="MJCTV84"
    $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
    $answer.AllElements|where class -eq "reset"|Select -First 1 -ExpandProperty innerText

    Now this come out whit all the info you need

    Hope this help


    Thursday, July 23, 2015 6:40 PM
  • Hey Frederick thanks for the answer. Is there anyway to clean it up to just say the expiration date?
    • Edited by Cody_Horton Thursday, July 23, 2015 6:57 PM
    Thursday, July 23, 2015 6:51 PM
  • Okay it's so close thanks for all the help so far everyone!

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
    $form = $test.forms[4]
    $form.Fields["serialCode"]="MJCTV84"
    $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
    $answer.ParsedHtml.getElementById("warranty_result_div").outerText

    This displays this 

    Start Date: 
    2010-03-18 
    End Date: 
    2013-03-27 
    Warranty Type: 
    36Y 
    Status: 
    Expired 
    Serial Number: 
    MJCTV84 
    How can I just get the 4th line? Thanks for all the help again!!
    Thursday, July 23, 2015 7:11 PM
  • This seems like it works fine I doubt the output will ever change so the substring should work. Thanks for all the help!! I'll mark Frederick as the answer and thanks for the help JRV. I know officially Lenovo doesn't support it but while I can I really want to get this info automatically with no human error. Everything else in the DB is automatically pulled in. If anyone has a prettier way of doing it I would love to see. Thanks!!

    Here's what I ended up with:

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
        $form = $test.forms[4]
        $form.Fields["serialCode"]="$($serial)"
        $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
        $a = $answer.ParsedHtml.getElementById("warranty_result_div").outerText
        $a.Substring(39,10)

    • Marked as answer by Cody_Horton Thursday, July 23, 2015 7:55 PM
    • Unmarked as answer by Cody_Horton Thursday, September 24, 2015 1:12 PM
    Thursday, July 23, 2015 7:46 PM
  • Apparently SaS provides this for both Lenovo and IBM.  IBM has already changed their warranty search and provided a protected service for customer access.  I suspect that Lenovo will not be far behind.

    \_(ツ)_/

    Thursday, July 23, 2015 8:01 PM
    Moderator
  • Okay awesome that's good to hear. Well I'll use this as a bandage till that time comes. Thanks for all the help JRV.
    Thursday, July 23, 2015 8:12 PM
  • You are welcome.  I suggest polling Lenovo to see if they may have already implemented the web service.


    \_(ツ)_/

    Thursday, July 23, 2015 8:15 PM
    Moderator
  • It looks like Lenovo has has changed something: You'll need to replace forms[4] to forms[0] to get this to work.
    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
    $form = $test.forms[0]
    $serial = 'MJNECHL'
    $form.Fields["serialCode"]="$($serial)"
    $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
    $a = $answer.ParsedHtml.getElementById("warranty_result_div").outerText
    $a.Substring(39,10)
    Thanks I figured I would update this in case it helps anyone. I saw someone had done this from a comment on this post: http://www.scconfigmgr.com/2015/03/21/get-lenovo-warranty-information-with-powershell/
    • Marked as answer by Cody_Horton Thursday, September 24, 2015 1:12 PM
    Thursday, September 24, 2015 1:12 PM
  • Thanks for the reply jrv.

    Looks great!

    Thursday, October 01, 2015 8:04 AM
  • Hi all,

    Looks like the powershell script isn't working anymore to get lenovo laptop warranty detail.

    $test = Invoke-WebRequest -uri http://support.lenovo.com/us/en/warrantylookup -SessionVariable ln
    $form = $test.forms[0]
    $serial = 'MJNECHL'
    $form.Fields["serialCode"]="$($serial)"
    $answer = Invoke-WebRequest -Uri ("http://support.lenovo.com" + $form.Action) -WebSession $ln -Method $form.Method -Body $form.Fields
    $a = $answer.ParsedHtml.getElementById("warranty_result_div").outerText

    It gives following error message:


    You cannot call a method on a null-valued expression.
    At line:7 char:5
    + $WebRequestResult.ParsedHtml.getElementById("warranty_result_div").outerText
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Any suggestions please?

    Tuesday, January 10, 2017 7:29 PM
  • You will need to have a valid account with Lenovo and contact Lenovo support for assitance:

    http://www.scconfigmgr.com/2015/03/21/get-lenovo-warranty-information-with-powershell/


    \_(ツ)_/

    Tuesday, January 10, 2017 7:32 PM
    Moderator
  • Hi All,

    Even we are facing the same issue. Script used is same as above.

    Please suggest.

    Wednesday, January 11, 2017 8:21 AM
  • Hi All,

    Even we are facing the same issue. Script used is same as above.

    Please suggest.

    You must contact Lenovo and acquire an account to use their web service.  It is no longer publicly available.


    \_(ツ)_/

    Wednesday, January 11, 2017 8:34 AM
    Moderator
  • Previously, It works for me.but suddenly I am getting this issue..

    Please need help on this

    You cannot call a method on a null-valued expression.
    At C:\Users\Administrator\Documents\GetWarranty.ps1:56 char:5
    +     $OuputResult2 = $WebRequestResult.ParsedHtml.getElementById("psp-section-war ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    Wednesday, January 11, 2017 9:35 AM
  • That website is now password protected and requires a Lenovo support account.  Post i Lenovo forum to find out how to do this now. This is not a scripting issue.


    \_(ツ)_/

    Wednesday, January 11, 2017 9:37 AM
    Moderator
  • Curious if anyone from Lenovo has gotten back to you about this after posting on their fourm? I do have a Lenovo support account and was able to sign into it but still i am presented with the same error.
    • Proposed as answer by TrentR1 Monday, June 05, 2017 6:13 PM
    • Unproposed as answer by TrentR1 Monday, June 05, 2017 6:13 PM
    Monday, January 23, 2017 4:47 PM
  • You can request access via the eSupport email.  I was provided this by Lenovo today.  I don't have the infrastructure in place to test but I did want to provide what I found to the benefit of the forum/community.  

    Web API info:  http://supportapi.lenovo.com//Documentation/Index.html

    To request access, users may contact:   eSupport_-_Ops@lenovo.com  (note the underscores before and after the hyphen)

     

    The manual warranty look up site is here:  http://pcsupport.lenovo.com/us/en/warrantylookup

    • Can look up individual SN’s
    • Can look up in batch
    Monday, June 05, 2017 6:35 PM