Dell & HP Warranty Info from a CSV file of Tags

Updated: 2013-11-20 – Added User submitted version of script to downloads.

I have tweaked my powershell script for the SCCM Dell/HP tags due to popular demand so that it can be run on a single machine using a list of service tags as the source and then will output to a CSV file. The source CSV can have any number of columns however it MUST have the following three for the script to work “Name,Vendor,Tag” in its default state. You also need to edit the $infile & $outfile variables as required.

This can be changed if you wish by editing the following three lines in the “Main” function.

  • $tag = $entry.Tag
  • $manu = $entry.Vendor
  • $name = $entry.Name

Name = The Name of the system

Vendor = The Manufacturer of the system (dell or HP)

Tag = The service tag of the system.

As always any issues or feedback just leave a comment (or donate ;) )

Files:

28 thoughts to “Dell & HP Warranty Info from a CSV file of Tags”

  1. Is this script works now also. I can see both Dell and HP has implemented captcha for that. So I guess its not possible to bypass the captcha. So, Please let me know if anyone ahd recently tried this and found it working.

  2. Please have a look at the quotes in Nan’s version of your script.

    In both browsers I tried the quotes came out as � characters. For some reasons, notepad and powershell_ise does not work well with this character.

    not well = disastrously bad

  3. Does anyone know which url hp uses to query warranty information? Since the url in the script is no longer working…

  4. The current script is broken because HP no longer uses the URL that the script uses to query warranty information. The script will need to be modified to work with the current warranty look up URL.

    Nan

  5. Hi, Thank you for the script. I have disabled line 201 and the script started to work. but when checking some tags it goes bonkers and does not work correctly. Its to do with the date. as per the below.

    An example serial is CZC7472616

    Get-Date : Cannot bind parameter ‘Date’ to the target. Exception setting “Date”: “Object reference not set to an instan
    ce of an object.”
    At C:\Users\beast\Desktop\check.ps1:72 char:18
    + return get-date <<<< $tDate -UFormat "%Y-%m-%d"
    + CategoryInfo : WriteError: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

    Cannot convert value "" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
    At C:\Users\beast\Desktop\check.ps1:137 char:32
    + $daysleft = ([datetime]$eDate <<<< – [datetime]::today).days
    + CategoryInfo : NotSpecified: (:) [], RuntimeException
    + FullyQualifiedErrorId : RuntimeException

    Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
    At C:\Users\beast\Desktop\check.ps1:70 char:34
    + $tDate = [datetime]::ParseExact <<<< ($rawDate, $dformat, $null)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

  6. Nope I don’t mind at all, in fact I in courage the updating and customizing of my script by others.
    Ideally everyone would post back their tweaks so we could all benefit from optimizations / different use cases.
    If you don’t mind I’ll add that as a separate download in this post when I get a chance so it doesn’t clutter the comments.

  7. I hope the author doesn’t mind but I have modified the original script to not require an input file. The vendor and system serial number information is obtained at run time.

    Also this script fixes a bug in the parsing of the contract html table entries in the functions GetHPContracts (and very likely in the GetDellContracts as well) where there is not warranty information returned. This search will return only one entry and the .length() function will return the number of characters instead of the number of elements in the array. There is a check in this modified script for this condition.

    This was tested on HP systems only, but modifications were made to the function for querying Dell systems.

    Here is the full script:

    (Removed by Ryan as script is now included in main post)

  8. For those of you asking about the GetTagNumber function, it isn’t actually needed. You can comment out the line 261 in the posted file (line: “$tag, $manu, $name = GetTagNumber $entry”) and the script will execute fine.

  9. @Jack
    Unfortunately I can’t I have changed Jobs in September and am back in a DELL only shop so have no way to test LENOVO or HP.

    In saying that the script is highly modularised and the DELL and HP parts are in separate functions so there is no reason you couldn’t just split out those bits. There is no LENOVO parts though so you would have to write that yourself but should just mainly be getting the correct URL and the correct regex to parse the page.

    @Chris:
    Yes I believe it was sorted one or two comments up. I’ll try and verify that the script is up-to-date.

  10. Hi Ryan,
    May I ask that you add seperate scripts for these vendors, such as:
    > WarrantyInfoFromFileForHP.ps1
    > WarrantyInfoFromFileForDELL.ps1
    > WarrantyInfoFromFileForLENOVO.ps1
    Many Thanks!

  11. Hi

    Thnx for the script, works like a charm(after some debugging)

    FYI:
    the Parseexec Error is because of trailing spaces in the $rawDate variable.

    remove them via regex or whatever and it works (i also set the parseexec provider to InvariantCulture… (shouldn’t matter though)

    Greets

  12. Hi There,
    May I know how to run this utility, is there required if any software to run and generate the output?

    please need help.

    Thanks in advance,
    Suresh.k

  13. Hi im getting this error.

    Any help appreciated

    C:\WarrantyInfoFromFile.ps1
    Cannot index into a null array.
    At C:\WarrantyInfoFromFile.ps1:129 char:22
    + $ctable = $matches[ <<<< 1]
    + CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

    Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
    At C:\WarrantyInfoFromFile.ps1:70 char:34
    + $tDate = [datetime]::ParseExact <<<< ($rawDate, $dformat, $null)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Get-Date : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Object reference not set to an instance of an object."
    At C:\WarrantyInfoFromFile.ps1:72 char:18
    + return get-date <<<< $tDate -UFormat "%Y-%m-%d"
    + CategoryInfo : WriteError: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

    many Thanks

  14. Hi,

    I get the following errors tryihn to run the script.

    I’ve got about 3000 HP machines i need the warranty info for, any help appreciated:

    C:\WarrantyInfoFromFile.ps1
    Cannot index into a null array.
    At C:\WarrantyInfoFromFile.ps1:129 char:22
    + $ctable = $matches[ <<<< 1]
    + CategoryInfo : InvalidOperation: (1:Int32) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

    Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
    At C:\WarrantyInfoFromFile.ps1:70 char:34
    + $tDate = [datetime]::ParseExact <<<< ($rawDate, $dformat, $null)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Get-Date : Cannot bind parameter 'Date' to the target. Exception setting "Date": "Object reference not set to an instance of an object."
    At C:\WarrantyInfoFromFile.ps1:72 char:18
    + return get-date <<<< $tDate -UFormat "%Y-%m-%d"
    + CategoryInfo : WriteError: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

    Thanks

  15. NICE job Ryan! Thank you.

    Phil, if you perform this change:
    $enableDebug = $true # Prints out contents of some variables to console
    $enableTrace = $true # Enable console output showing which function you are in

    Than you will still get an error, but with an output to the file.

    If there is a better fix please do let me know.

  16. @Lat,

    Sorry for the delay in response, work is mad atm. In the script “$enableDebug = $true” + “$enabletrace = $true” and either send me the whole output or look for “NormalizeDates” in the output and let me know the next line (should be the contents of “$tDate”).

    Regards,

    Ryan

    P.S. I hope you meant “exploring” and not “exploiting” ;)

  17. Hi Ryan, just noticed this while I was exploting your site and decided to have a go at it.
    First issue I encountered was same as Phil’s which was fixed after I removed the line 201.
    Now I get the output generated, but all the lines under staus is showing as Expired.
    Not only that, but while running the script, I get alot of errors which I think is Date related:

    Get-Date : Cannot bind parameter ‘Date’ to the target. Exception setting “Date”: “Object reference not set to an instan
    ce of an object.”
    At C:\warranty\WarInfo.ps1:72 char:18
    + return get-date <<<< $tDate -UFormat "%Y-%m-%d"
    + CategoryInfo : WriteError: (:) [Get-Date], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.GetDateCommand

    Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
    At C:\warranty\WarInfo.ps1:70 char:34
    + $tDate = [datetime]::ParseExact <<<< ($rawDate, $dformat, $null)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    This makes me wonder, if we are in europe, does it mean we have to have some lines changed?

  18. Phil,

    Again there are still two entries for NBD support one that has started and one that will start in a years time. So which would you want reported?

    (I purposely chose this system as an example as it is the most exotic I have come accross)

    Ryan

  19. Phil,

    So in the case of this system what would you want to report?
    Description Provider Start Date End Date Days Left
    Complete Care DELL 6/28/2011 6/28/2014 1007
    Next Business Day Support UNY 6/29/2012 6/28/2014 730
    Client Gold Support / ProSupport DELL 6/29/2012 6/28/2014 730
    Next Business Day Support UNY 6/28/2011 6/28/2012 277
    Client Gold Support / ProSupport DELL 6/28/2011 6/28/2012 277

    Notice that two of the contracts start next year and thus are not currently active.

    Ryan

  20. Hi Ryan, I am only interested in the start date, end date and days left. not interested in the contract type. Seems will all this work you are doing ill have to make a donation :)

  21. The multiple entries is expected for each host. As a host may (and generally does) have multiple warranties associated with it and there is no way for me to really check programmatically which ones you care about.

    The way to verify the output is append a service tag to the end of the url in the script and view the page.

    You are more than welcome to send me a sample of the input/output and I’ll verify but I suspect the above answers your question.

    Ryan

  22. Hi ryan, thanks, that worked. However, I am getting duplicate entries for the same host (a few of them) with different days left. can i email you my csv output so that you can see?

  23. Phil,

    Remove line 201 I should have. Not sure how I missed that, perhaps I undid more than one action and it got put back in.

    I’ll upload the fix later.

    Ryan

  24. Hi Ryan

    once again, thanks for this. I have modified my sccm hardware report to export the contents to a csv file. In the csv file i have a few columns, i have modified the report to output the colums as Name=Computername, Tag=service Tag and Manufacturer=Dell. so the right columns are there with the right info. i have edited your script with the correct input and output files but when i run it i get the following error

    The term ‘GetTagNumber’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try ag
    ain.
    At C:\Scripts\WarrantyInfoFromFile.ps1:201 char:38
    + $tag, $manu, $name = GetTagNumber <<<< $entry
    + CategoryInfo : ObjectNotFound: (GetTagNumber:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    any ideas?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.