Dell & HP Warranty Info in SCCM

Updated: 2011-08-18

This is the next evolution in the warranty info fight, Dell keep changing their site which is rather frustrating. I have re-written the Warranty Info Scripts in powershell as in my opinion the code is a lot cleaner and more manageable, I’ve tweaked the MOF edit required to read this.

One major change to the script is that I have added support for HP systems, now I must stress I only have one or two of these, both are out of warranty and only had base warranties so something may have been missed / may not work as expected. You can either fix it and let me know the changes you make or let me know, via the contact page, the tag of one of your systems and I will look at it when I get a chance.

If you use any other version of the script from my site you will need to update sms.mof as the reports have changed.

I am quite shameless so if you find this useful feel free to click on donate and well, donate. :D

What info do you get?

  • Index – Really just a count of each warranty instance – Not reported by default
  • DateScriptRan – Date and time the script was run – Default
  • Description – This is the blurb that tells us what the warranty is – Default
  • Provider – Dell provide this in their info, I fill in HP’s with “HP” – Default
  • StartDate – Date the warranty started
  • EndDate – Date the warranty Expires
  • DaysLeft – Number of days left on the warranty on the day the script was run (dell provide this, I calculate it for HP) – Not reported by default as I think it makes more sense to calculate in SQL when the report is run
  • Status – “Active” or “Expired” this is provided by HP and calculated by me for Dell, note it may be possible for a system to have 1 warranty expired but another active so check your reports carefully – Default

Usage:

  • Create a single package in SCCM containg all 3 scripts and the cmd file.
  • Create 3 programs in the package called “System Script 1”, “User Script”, “System Script 2” using the cmd file to run them
    “powershell.cmd systemscript1.ps1” …
  • Make “System Script 2” depend on “User Script” being run 1st (Using Run this program 1st option)
  • Make “User Script” depend on “System Script 1” being run 1st (Using Run this program 1st option)
  • System Scripts should run as admin and whether or not a user is logged in, User Script runs as user only when logged in.
  • Advertise”System Script 2″ to the collection as a mandatory assignment
  • Added the contents of the MOF file to your sms_def.mof
  • Copy the report “.mof” files to the sccm server, right click on reports in sccm console, choose “import object” and import them.
Program dependancies for powershell warrantyinfo

Known Issues:

  • The reports might need tweaking to your environment (especially if you have used an earlier version of the scripts.)
    • Right click on the report, choose properties, “Edit SQL Statement”
    • Browse the “Views” box until you find “v_GS_WarrantyInfoX” (where X is a number)
    • Click on “v_GS_WarrantyInfoX” and check that the fields on the right match those in the query below.
  • To work around the system account not being able to access the internet there are 3 scripts, 2 that run as admin and one that runs as the current logged in user, they must be run in sequence. This is mainly for vista/7 support as XP users can run the monalithic script as the themselves if they are admins.
  • A command prompt flashes on screen briefly.

ToDo:

  • Get rid of command prompt appearence.
  • Reduce to single script if at all possible for Vista/7

Updates:

  • 2011-08-18
    • Fixed call to “GetHPDaysLeft” using 2 parameters (the one that was being used was incorrect) instead of 1 (User Script)
  • 2011-07-28
    • Fixed $warrantydir not being removed. (System Script 2)
  • 2011-07-28
    • Fixed issue where Dell Warranties starting in the future placed extra tags around the days left.
  • 2011-07-26
    • Fixed Report MOF import error.
  • 2011-07-20
    • Fixed an invalid function call in “system 2” script.
  • 2011-07-08:
    • Fixed WMINamespace path in “system 2” script it was placing the class in the wrong location so sccm wasn’t picking up details (if you really want to clean up incorrect entry you could tweak the system 2 script to call the DeleteWMI function with the old path to the class)
    • Added reports

Files:

  • [download id=”27″]
  • [download id=”28″]
  • [download id=”29″]
  • [download id=”30″]
  • [download id=”31″]
  • [download id=”32″]
  • [download id=”33″]

55 thoughts to “Dell & HP Warranty Info in SCCM”

  1. I runing sequence:
    1º powershell.cmd WarrantyInfo-System1.ps1
    2º powershell.cmd WarrantyInfo-User_ps.ps1
    3º powershell.cmd WarrantyInfo-System2.ps1

  2. I use your script, but the SystemScript2.ps1 don’t change values in WMI.
    DateScriptRan, Description, Provider, StartDate, EndDate, DaysLeft, Status, all = NULL.
    you have idea to be wrong ?

  3. Is there a way to use this for just running 100 service tags I can input in a text or csv file? I don’t have access to the SCCM server but I need to look up the warranty status. Thanks in advance.

  4. Hi ryan

    thank you very much for your efforts so far, i really appreciate it. I will check back next week some time for a possible update.

    have a good weekend

  5. Phil,

    When I initially created the scripts the target was really enduser system hence the design reflects that. As per pulling the tags from SCCM then and producing a report, the thought had crossed my mind and it would be a trivial task to tweak the current scripts to do just that (I actually have a single script version that I use for testing). The problem I faced was that I couldn’t work out a way to get that information into sccm efficiently without directly accessing and change the database which is not something I would do unless it was absolutely critical. I wanted a single pane of glass for the reports not adhoc ones. Aside from that the only reason there isn’t a script to do that, is I just haven’t had time to sit down and just do it.

    Looking at the comments from yourself and Lat, I think that a script of that type might be useful. I’ll try and take some time next week on my lunch hour to fire something together.

    Your commandlines look correct, do all the systems have powershell installed? I don’t think XP & server 2003 will.

    Yes trying to run the script on a VM will fail to find a service tag. ;) I probably should have coded a graceful fail but again lack of time.

    Regards,

    Ryan

  6. Ryan

    Apologies for all my posts, but i just got thinking about the way your script works. I am no scripting fundy by any means but i was wondering if this would not make a bit more sense.

    Instead of having the user powershell script having to execute on each and every server/workstation (pre reqs that that machine has internet access) doesnt it make more sense that the script get the asset tags from the sccm db itself, then does the lookup once from the sccm server and then outputs that to a report?

    The downfall of the way its working now is that every device needs to have internet access for the user script to execute and as for the server part, for every server you want to query a user must be logged onto that server. (as well as have internet access)

    Let me know your thoughts on this.

  7. ok my programs are failing to execute. Can you please confirm the command line for the program. I have

    powershell.cmd WarrantyInfo-System1.ps1

    for each program, is this correct?

  8. Ryan the script was failing because i ran it on a vm and not a physical dell system, bit of my own retardedness there. Definitely only have v_GS_Warranty_Info0.

  9. Phil,

    How did you solve the proxy issue out of curiosity?

    With regards to the report, do you definately only have v_GS_Warranty_Info0 and not a v_GS_Warranty_Info1 or higher?

    Ryan

  10. Hi ryan, thanks for the response, i got past the proxy issue. I just have another query re the report for a specific computer. I have modified it to run on a collection rather (a collection where my physical dell servers live, and not my vmware servers) all servers accept my program. In the report section, where you mention one should tweak it. i see the v_gs_warrantyinfo0 there, but on the right hand side i see nothing that matches the query. on the right i see AgentID, GroupID, Index0, ResourceID, Revision ID and Timestamp. That matches up with nothing i have in the query below. So its not even if you can go and tweak the report and try and match it up. Any thoughts?

  11. Phill,

    I can’t comment for sure as I don’t use proxies, but two things to note that might affect this.

    1) The User script REQUIRES a user to be logged on to run as it uses their credentials to access the internet, so this may be an issue on servers.

    2) This is just a hunch but can you check the proxy settings for the default bowser for the user the user script is running as? if there are not set then set them and see if it works then.

    Regards,

    Ryan

  12. Hi there, thanks for this, i have read through all the comments but i didnt get my answer there. is there a special way to get through a proxy, to get to the internet? our servers and workstations use different proxies, on my workstation the script runs, on our servers not. (the user script) it just fails with “an error has occured” and thats about it. the proxy guys arent even seeing requests from the server to the proxy when executing the script. any suggestions?

  13. I think desktops were fine all along. My main interest in this is the servers.
    I only tried it on my desktop which is Windows 7 and it was working fine.

    Basically I have been asked to get all the warranties for all our Dell servers (500+) with various Windows operating systems. Some with Powershell and some without.
    It is a big task.

  14. Lat,

    I have a hunch, try disabling IE SEC for all users. If that works then you should be able to re-enable it and add the dell site to trusted sites.

    EDIT: Oh meant to ask, what did you need to do in the end to get it working on your desktops?

    Regards,

    Ryan

  15. Hi Ryan,

    Been away last couple weeks and managed to get this working on Windows 7 desktops on my return.

    I still have issues getting this to run on a server unfortunately and issue seems to be with running WarrantyInfo-User.ps1 script.

    When I do, I get:
    Exception calling “DownloadString” with “1” argument(s): “Unable to connect to the remote server”
    At C:\warranty\WarrantyInfo-User.ps1:228 char:57
    + $content = (new-object net.webclient).DownloadString <<<< ($DellURL)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Cannot index into a null array.
    At C:\warranty\WarrantyInfo-User.ps1:102 char:19
    + return $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:\warranty\WarrantyInfo-User.ps1:92 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 instan
    ce of an object."
    At C:\warranty\WarrantyInfo-User.ps1:94 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\WarrantyInfo-User.ps1:92 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 instan
    ce of an object."
    At C:\warranty\WarrantyInfo-User.ps1:94 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\WarrantyInfo-User.ps1:92 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 instan
    ce of an object."
    At C:\warranty\WarrantyInfo-User.ps1:94 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\WarrantyInfo-User.ps1:92 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 instan
    ce of an object."
    At C:\warranty\WarrantyInfo-User.ps1:94 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\WarrantyInfo-User.ps1:92 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 instan
    ce of an object."
    At C:\warranty\WarrantyInfo-User.ps1:94 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\WarrantyInfo-User.ps1:92 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:\warranty\WarrantyInfo-User.ps1:94 char:18
    + return get-date <<<

  16. @nature_boy
    Thanks for pointing that out, I didn’t really spend much time on the HP part as I only have about 3 servers all out of warranty.
    I’ll get a fix uploaded tonight or tomorrow morning.

    Ryan

  17. Nice Tool!

    I think this line in downloads/2011/07/WarrantyInfo-User_ps.txt needs to be changed:
    From -> $Contract.DaysLeft = GetHPDaysLeft $Contract.StartDate $Contract.EndDate #Count days left
    To -> $Contract.DaysLeft = GetHPDaysLeft $Contract.EndDate #Count days left

  18. Nevermind, adding -force to the end of the line seemed to fix it.

    Changed code:
    Remove-Item -Recurse $warrantyInfoDir -force

  19. Yep, the csv file looks good! My only remaining problem is with the systemscript2, I get a permissions error when it tries to remove the hidden directory. This is the output from powershell ISE running as administrator.

    Remove-Item : Cannot remove item C:\warrantyinfo: Not Enough permission to perform operation.
    At C:\Users\\Desktop\dellwarrantysccm\systemscript2.ps1:88 char:14
    + Remove-Item <<<< -Recurse $warrantyInfoDir
    + CategoryInfo : PermissionDenied: (C:\warrantyinfo:DirectoryInfo) [Remove-Item], IOException
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand

  20. theDude,

    Your issue with the italics should be solved now. Please redownload the user script and try again.

    Lat,

    I can’t reproduce your issue. Both your tags are importing fin on my machine when I run the scripts. Are those the tags you are testing with? and what OS are you using?

    Regards,

    Ryan

  21. I’ve fixed the import issue with the report MOF files

    I’ve also Updated the Known Issues section with details about the Reports.

    Generally speaking my MOF files will work for 1st time users, others may need to ensure the numbers appended to the View and Fields match the query.

    Diego,
    Try prefxing the fields in the query with “vgswi.” e.g. “vgswi.Description0”

    only_me,
    Try incrementing the “v_GS_Warranty_Info0” e.g “v_GS_Warranty_Info1” “v_GS_Warranty_Info2” … and see if it works.

    Regards,

    Ryan

  22. Hello,
    Same issue in reporting here:
    “An error occurred when the report was run. The details are as follows:
    Ambiguous column name ‘Description0’.
    Error Number: -2147217900
    Source: Microsoft OLE DB Provider for SQL Server
    Native Error: 209

    Thx.

  23. don’t have the ““Invalid object name ‘v_GS_Warranty_Info0′.” anymore, but now i’m getting :

    Invalid column name ‘Description0’.

  24. thanks,

    but i’m getting another problem, when i try to run the report i get:
    “Invalid object name ‘v_GS_Warranty_Info0’.”

  25. “Diego,

    I had the same problem. If you open the file, you will see that line which begins with \nDATEDIFF(DAY,GETDATE()……. is on two lines.
    Could be the way original text was formatted.

    If you fix this, it should work.”

    so what i need to change to correct the report?

  26. Thanks Lat for that answer, Sorry about that Diego, that was an unintended side effect of me editing the report after I exported it to add that datediff in. I’ll re-export the reports as soon as I get a chance to correct that.

    Thanks Lat for the tags, I’ll try and get a chance to do some debugging this week.

    Regards,

    Ryan

  27. Diego,

    I had the same problem. If you open the file, you will see that line which begins with \nDATEDIFF(DAY,GETDATE()……. is on two lines.
    Could be the way original text was formatted.

    If you fix this, it should work.

  28. I’ve followed all the steps but I can’t import the mof reports.

    I’m getting a parsing error (Code 80044007).

    Anyone can help me?

  29. theDude,

    Thanks for reemailing that tag, I hadn’t got it the 1st time (it was your post that tipped me off to the problem). I think I know what the problem is, if you look on the webpage those 2 are in itialics in the table, I think I am not stripping the tags out completely and that is why you are getting the problem

    Lat,
    Are your Tags US ones? and could you send me one via the contact page so I can compare to theDude’s as I am wondering if you are suffering from the same issue as he is.

    Regards

  30. Lat,

    What OS are you testing on?
    I’ve only tested on Windows 7 x64.

    I’ve just run the scripts on my machine directly after downloading from here and it works fine (bar one error about removing the warrantyinfo folder, which I will track down in a bit)

    Regards,

    Ryan

  31. Thanks Ryan, that resolved it.
    So far I am able to run WarrantyInfo-System1.ps1 and WarrantyInfo-User.ps1 successfully.

    When I try and run WarrantyInfo-System2.ps1, I get the following error:

    PS C:\> .\WarrantyInfo-System1.ps1
    PS C:\> .\WarrantyInfo-User.ps1
    PS C:\> .\WarrantyInfo-System2.ps1
    Set-WmiInstance : Input string was not in a correct format.
    At C:\WarrantyInfo-System2.ps1:58 char:27
    + $res = Set-WmiInstance <<<< -Class $WMICLassName -Arguments $InstArgs -N
    amespace $WMINameSpace
    + CategoryInfo : NotSpecified: (:) [Set-WmiInstance], FormatExcep
    tion
    + FullyQualifiedErrorId : System.FormatException,Microsoft.PowerShell.Comm
    ands.SetWmiInstance

    Any ideas?

  32. lat,

    That must have slipped by, when I wrote the inital script it was monolithic. To then work around the limitations of the system account I split the script.
    Cleanup is actually defined in the userscript.

    Just remove it from the end of the “Main” function.
    I’ll do the same on the site thanks for pointing that out.

    Regards,

    Ryan

  33. I am trying to test each of the .ps1 files to make sure they function. When I try and run WarrantyInfo-System2.ps1, I get an error:

    “The term ‘Cleanup’ 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 inc
    luded, verify that the path is correct and try again.
    At C:\WarrantyInfo-System2.ps1:87 char:10
    + Cleanup <<<<
    + CategoryInfo : ObjectNotFound: (Cleanup:String) [], CommandNotF
    oundException
    + FullyQualifiedErrorId : CommandNotFoundException"

    Sounds like it is not a PS command??

  34. theDude,

    Can you send me one of your tags that you see this behaviour on via the contact page?

    I am not sure why it would be trying to format the days left. if should be plain text / int.

    Ryan

  35. edit, maybe because it’s actually writing the Days Left value as an italicized # i.e. 730

  36. Here’s a little oddity. We have extended warranties on all our clients that don’t start until a year from the ship date or however they classify it. So for example, one warranty doesn’t start until 2012-06-28, even though all the other values are correct, including the days remaining, it shows the status as “Expired”

  37. It’s fairly straight forward.

    Create a package on the sccm server containing:
    user script
    System Script 1 & 2
    powershell.cmd

    create 3 programs in the package with the following command lines
    powershell.cmd UserScript.ps1
    powershell.cmd SystemScript1.ps1
    powershell.cmd SystemScript2.ps1

    Open the properties of programs “systemscript2” and “userscript”

    Click on the advanced tab

    Tell the SystemScript2 to run another program 1st and point it at the UserScript

    Tell the UserScript to to run another program 1st and point it at SystemScript1

    Append the contents of the “warrantyinfo.mof” to the bottom “sms_def.mof”

    Advertise SystemScript2 to a collection

    Copy the report “.mof” files to teh sccm server right click on reports in the console and choose import object and import the reports.

Leave a Reply

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

*

This blog is kept spam free by WP-SpamFree.