1 2 Previous Next 16 Replies Latest reply on Jul 31, 2013 1:32 AM by Cyril.DORCY1

    Script to query dell warranty and write to registry

    derekhamaker Apprentice

      I currently have about 4300 end points. About 95% are Dell machines.

      To date, we have no easy way to pull warraty info, other than exporting specific queries and copying the Service Tags into another script.

       

      I would like to deploy a script (local and via gateway) that will query the device service tag; go to Dell and check warranty info; and report that info into the registry.

       

      I have this VBS (copied below and attached) (courtesy of http://iboyd.net/index.php/2012/02/14/updated-dell-warranty-information-script/)

       

      I remarked out all the wscript.echo in my actual script that I have run.

      This prevents the series of pop ups.

       

      When I run this local (from desktop or network source) it works perfect.

      I get a series of registry keys under HKLM\Software\DellWarrantyInfo that provide me all the warranty info I'm looking for.

       

      When I deploy this to targets as a "Windows Script Host" it doesn't seem to run.

      I have tried without the remarked out lines and with full UI. I get prompted to Deploy, but nothing runs.

       

      log..jpg

      We will build this into our future templates for imaging, but I'd really like to get this info into the registry for existing machines.

      Any help you can provide, I'd be greatful.

      Thanks!

      -Derek

       

      '=====================================================================
      '    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/WebServices/""> <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/services/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/WebServices/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
      
      
        • 1. Re: Script to query dell warranty and write to registry
          MarXtar ITSMMVPGroup

          What route to the internet do the machines have? Do they need to go via a proxy and does that require authentication? When you deploy with LANDesk it will be running as local system so you may have internet access issues. 9.5 would allow you to run as a specific user account if needed.

           

          I assume you know this capability and more if available via the LANDesk Data Analytics module? This would have the added benefit of handling this from a central point rather than needing each machine to connect to the internet to pull down information. There is a cost associated but it is extremely powerful.

           

          Mark McGinn

          MarXtar Ltd

          http://landesk.marxtar.co.uk

          LANDesk Silver ESP

           

          The One-Stop Shop for LANDesk Enhancements

          - Wake-On-WAN - Distributed Wake-On-LAN, Scheduled Power Down, and SWDist Sequencing

          - State Notifier - Real-Time Device & User State Inventory Updating & Alerting

          Update - WoW & State Notifier now integrate for even more functionality

          Update - State Notifier now detects machine and user Idle states

          • 2. Re: Script to query dell warranty and write to registry
            Apprentice

            Hi,

             

            Script's Note indicates : "Note: This must be run under an account with admin rights."

             

            Have you tried to schedule the script under a specific admin account ?

             

            Regards

            • 3. Re: Script to query dell warranty and write to registry
              derekhamaker Apprentice

              Yes, I am aware of the Analytics product. It's not in the budget.

              Besides, this script, if I can get it working will give me the same info - and at no cost.

              The issue is just that it's not working when deployed. It works fine run locally.

              -Derek

              • 4. Re: Script to query dell warranty and write to registry
                derekhamaker Apprentice

                It is being run as the local system account - which DOES have local admin.

                It is the same account used to deploy software installs, which as we all know, regularly modifies the same HKLM\Software keys

                • 5. Re: Script to query dell warranty and write to registry
                  MarXtar ITSMMVPGroup

                  Understood about costs, just wanted to check, but all admins are not equal. The local system account does have LOCAL admin, but doesn't have any authenticated network rights which is why I ask the route to the internet. How is access granted, via authenticating proxy or direct? I'd suggest you put some checks in there to verify that it is actually executing, and what is happening at each stage. Get it to output different items to a log file so you can see what it is collecting at each stage. It may be the internet that fails, it may be the WMI access, it may even be that it isn't executing at all.

                   

                  9.5 would let you launch as a specific user account which 'should' get over this type of issue, but as you are unlikely to be on that version yet, you need to do the standard checks of whether the local system account behaves the way you would expect.

                   

                  Mark McGinn

                  MarXtar Ltd

                  http://landesk.marxtar.co.uk

                  LANDesk Silver ESP

                   

                  The One-Stop Shop for LANDesk Enhancements

                  - Wake-On-WAN - Distributed Wake-On-LAN, Scheduled Power Down, and SWDist Sequencing

                  - State Notifier - Real-Time Device & User State Inventory Updating & Alerting

                  Update - WoW & State Notifier now integrate for even more functionality

                  Update - State Notifier now detects machine and user Idle states

                  • 6. Re: Script to query dell warranty and write to registry
                    Apprentice

                    Hi,

                     

                    I Have the same issue here. After few tests, here is what I noticed :

                    • cscript.exe DellWarrantyGrabber.vbs in an admin elevated cmd windows works like a charm.
                    • cscript.exe DellWarrantyGrabber.vbs in a SYSTEM cmd windows works like a charm (I used psexec from sysinternals to obtain a SYSTEM CMD)
                    • Scheduled LANDESK Windows Host Script Package return  : task complete (but nothing appended in the registry)
                    • LANDESK Batch (launching VBS) package scheduled  Return task complete but nothing append

                     

                    In the Client's log file I noticed that script was correctly executed because of script's output is in the log with right information :

                    -------------------------------------------------------------------------------------------------------------------------------------

                    Tue, 13 Nov 2012 12:55:47 3760 2812 Bat file output :   C:\Program Files (x86)\LANDesk\LDClient\sdmcache\packages\Apps\Systeme\Asset>call "DellMostRecentWarrantyGrabber.bat"    Microsoft (R) Windows Script Host Version 5.8  Copyright (C) Microsoft Corporation 1996-2001. Tous droits r‚serv‚s.    warranty End Date : 2009-10-14

                    -------------------------------------------------------------------------------------------------------------------------------------

                     

                    So it seems that registry commands are the issue.

                    • 7. Re: Script to query dell warranty and write to registry
                      Apprentice

                      Testing ObjShell.regwrite return Err.number code = 0

                       

                      So it seems to to be happy but dosen't write anything in the registry !?!

                       

                       

                      • 8. Re: Script to query dell warranty and write to registry
                        Apprentice

                        Hi evreybody,

                         

                        I think I've found !

                         

                        Well In fact, script is running as well as expected. But default package settings is to execute the scripts as a 32 bits script. So Regsitry keys are not written to "HKEY_LOCAL_MACHINE\Software\DellWarrantyInfo" but in "HKEY_LOCAL_MACHINE\Software\Wow6432Node\DellWarrantyInfo"

                         

                        To obtain what we want, we had to enable the "run as 64bit application" option in the package settings.

                         

                        Regards

                        • 9. Re: Script to query dell warranty and write to registry
                          Apprentice

                          Hi,

                           

                          Here is my tribute to the community. These are 2 customized version of the original iBoy's scritps

                           

                          1st one : DellMostRecentWarrantyGrabber.vbs :

                           

                          I want to Know : Is System Warranty or not ?

                           

                          - Only synthetic information about warranty status at top level registry key

                             - System Ship Date : System Ship Date

                             - Start Date : Start Date of the 1rst contract

                             - End Date : End Date of the most recent contract

                             - Entitlement Type : Status of the most recent contract

                             - Days Left : Days Left of the most recent contract

                             - And a few others informations

                          - Add some error controls

                          - Add Language customization (US + FR)

                             -  FR Customization to obtain french registry keys and date in DD/MM/YYYY format

                           

                          OUTPUT REGISTRY EXEMPLE :

                           

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Warranty]

                          @=""

                          "System Ship Date"="2010-03-24"

                          "Service Tag"="G4BNGNP"

                          "System ID"="lat_e4200"

                          "Buid"="909"

                          "Region"="Europe"

                          "System Type"="Latitude"

                          "System Model"="E4200"

                          "Start Date"="2010-03-24"

                          "Provider"=""

                          "Entitlement Type"="Active"

                          "End Date"="2013-03-25"

                          "Days Left"="131"

                           

                          2nd one : DellAllWarrantyGrabber.vbs :

                           

                          I want to Know : Is System Warranty or not + Detailed Warranty contract

                           

                          - Synthetic information about warranty status at top level registry key

                             - System Ship Date : System Ship Date

                             - Start Date : Start Date of the 1rst contract

                             - End Date : End Date of the most recent contract

                             - Entitlement Type : Status of the most recent contract

                             - Days Left : Days Left of the most recent contract

                             - And a few others informations

                          - Detailed information about warranty status of each contract in subkeys

                          - Add some error controls

                          - Add Language customization (US + FR)

                             -  FR Customization to obtain french registry keys and date in DD/MM/YYYY format

                           

                          OUTPUT REGISTRY EXEMPLE :

                           

                          Windows Registry Editor Version 5.00

                           

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Warranty]

                          @=""

                          "System Ship Date"="2007-10-25"

                          "Service Tag"="676G73G"

                          "System ID"="PLX_PNT_P4_745"

                          "Buid"="909"

                          "Region"="Europe"

                          "System Type"="OptiPlex"

                          "System Model"="745"

                          "Start Date"="2007-10-25"

                          "End Date"="2012-10-25"

                          "Entitlement Type"="Expired"

                          "Days Left"="0"

                           

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Warranty\0]

                          @=""

                          "Provider"=""

                          "Start Date"="2010-10-25"

                          "End Date"="2012-10-25"

                          "Entitlement Type"="Expired"

                          "Days Left"="0"

                           

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Warranty\1]

                          @=""

                          "Provider"=""

                          "Start Date"="2007-10-25"

                          "End Date"="2010-10-25"

                          "Entitlement Type"="Expired"

                          "Days Left"="0"

                           

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Warranty\2]

                          @=""

                          "Provider"=""

                          "Start Date"="2007-10-25"

                          "End Date"="2010-10-25"

                          "Entitlement Type"="Expired"

                          "Days Left"="0"

                           

                          [HKEY_LOCAL_MACHINE\SOFTWARE\Dell\Warranty\3]

                          @=""

                          "Provider"=""

                          "Start Date"="2007-10-25"

                          "End Date"="2008-10-25"

                          "Entitlement Type"="Expired"

                          "Days Left"="0"

                           

                          Tested successfully with WSH Package in LANDesk environment.

                           

                          Best Regards

                          • 10. Re: Script to query dell warranty and write to registry
                            Apprentice

                            Hi,

                             

                            Here is the new verion of my custom scripts.

                             

                            What's New :

                            • Rewrite WMI calls to use standard object's collections : Thousands of computers where the code crashed WMI
                            • Ability to choose a Test Service Tag
                            • Thousands of code optimization
                            • Date output format choice "ISO8601" (default), "US" or "FR"
                            • DaysLeft string now always on 4 or more chars for sort purpose
                            • Thousands of Controls improvements in case of blank fields at Dell's web services

                             

                            Tested over ~200 PC

                             

                            Best Regards.

                            • 11. Re: Script to query dell warranty and write to registry
                              Apprentice

                              What about you derekhamaker ?

                               

                              Have you tried my custom scripts ?

                              • 12. Re: Script to query dell warranty and write to registry
                                derekhamaker Apprentice

                                Hey Cyril!

                                Wow!! Thanks so much for all your help and work.  I have been traveling quite a bit, but am working to test this now.

                                I"ll report back my findings shortly!

                                -Derek

                                • 13. Re: Script to query dell warranty and write to registry
                                  derekhamaker Apprentice

                                  Works like a charm!

                                  Thanks so much for all your help.

                                  You are truly a testament to why this community forum is such a valued resource to any LANDesk user.

                                  -Derek

                                  • 14. Re: Script to query dell warranty and write to registry
                                    Apprentice

                                    Glad to know it works for you too.

                                     

                                    Cyril.

                                    1 2 Previous Next