a few days ago my boss liked to see a list of all our computers with the warranty informations like purchase date and warranty end date. So i wrote this little vbscript, witch collect the information from the manufacturers webpage (in our case HP, Dell and Maxdata) and write it to a MIF file.
Please have a look at the script or download it here:
' =========================================================================================== ' ' Script Information ' ' Title: WarrantyInformations.vbs ' Author: Josua Burkard ' Date: 16.11.2011 ' Description: get Warranty Informations from HP, Dell, or MaxData Computers ' - writes the information to SCCM MIF file ' ' =========================================================================================== ' =========================================================================================== ' Constants ' =========================================================================================== Const CREDENTIALS_FOR_SERVER = 0 Const CREDENTIALS_FOR_PROXY = 1 Const HTTPREQUEST_PROXYSETTING_PROXY = 2 Const NETWORK_CONNECTIONS = &H31& Const ForAppending = 8 Set objShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Const strMifFile = "\WarrantyInfo.mif" strSerialNumber = GetSerialNumber() strManufacturer = GetManufacturer() ' =========================================================================================== ' Start Test ' =========================================================================================== ' strSerialNumber = "30326050014" ' strManufacturer = "MAXDATA" ' =========================================================================================== ' End Test ' =========================================================================================== If strManufacturer = "Hewlett-Packard" OR strManufacturer = "HP" Then arrWarranty = GetHPWarranty(strSerialNumber) ElseIf strManufacturer = "Dell Inc." Then If Left(strSerialNumber, 1) = "." Then strSerialNumber = GetBiosSerialNumber() End If arrWarranty = GetDellWarranty(strSerialNumber) ElseIf UCase(strManufacturer) = "MAXDATA" Then arrWarranty = GetMaxdataWarranty(strSerialNumber) ElseIf Left(UCase(GetBiosVersion()), 6) = "MAXDAT" Then ' Manufacturer is 'MaxData' but Board Information says 'Intel' strBiosSerialNumber = GetBiosSerialNumber() arrWarranty = GetMaxdataWarranty(strBiosSerialNumber) Else ' Other or unknown manufacturer ' GetBiosInfo Wscript.Quit End If ' =========================================================================================== ' Write Temp File ' =========================================================================================== strTempDir = objShell.ExpandEnvironmentStrings("%TEMP%") If objFSO.FileExists(strTempDir & strMifFile) Then objFSO.DeleteFile(strTempDir & strMifFile) End If Set objMifFile = objFSO.OpenTextFile(strTempDir & strMifFile, ForAppending, True) objMifFile.Writeline "Start Component" objMifFile.Writeline " Name = " & Chr(34) & "WORKSTATION" & Chr(34) objMifFile.Writeline " Start Group" objMifFile.Writeline " Name = " & Chr(34) & "WarrantyInfo" & Chr(34) objMifFile.Writeline " ID = 1" objMifFile.Writeline " Class = " & Chr(34) & "WarrantyInfo" & Chr(34) objMifFile.Writeline " Start Attribute" objMifFile.Writeline " Name = " & Chr(34) & "WarrantyBeginn" & Chr(34) objMifFile.Writeline " ID = 1" objMifFile.Writeline " ACCESS = READ-ONLY" objMifFile.Writeline " Storage = Specific" objMifFile.Writeline " Type = String(100)" objMifFile.Writeline " Value = " & Chr(34) & arrWarranty(0) & Chr(34) objMifFile.Writeline " End Attribute" objMifFile.Writeline " Start Attribute" objMifFile.Writeline " Name = " & Chr(34) & "WarrantyEnd" & Chr(34) objMifFile.Writeline " ID = 2" objMifFile.Writeline " ACCESS = READ-ONLY" objMifFile.Writeline " Storage = Specific" objMifFile.Writeline " Type = String(100)" objMifFile.Writeline " Value = " & Chr(34) & arrWarranty(1) & Chr(34) objMifFile.Writeline " End Attribute" objMifFile.Writeline " End Group" objMifFile.Writeline "End Component" objMifFile.Close ' =========================================================================================== ' Move Temp file to MIF-directory ' =========================================================================================== strNoIDMifDir = GetMifFileDirectory() If objFSO.FileExists(strNoIDMifDir & strMifFile) Then objFSO.DeleteFile(strNoIDMifDir & strMifFile) End If objFSO.CopyFile strTempDir & strMifFile, strNoIDMifDir & strMifFile Function GetMifFileDirectory() ' =========================================================================================== ' Returns the Directory for SCCM MIF-file ' =========================================================================================== strWinDir = objShell.ExpandEnvironmentStrings("%WINDIR%") strComputerName = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%") strProcessorArchitecture = objShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") If strProcessorArchitecture = "AMD64" Then strNoIDMifRegLocation = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\SMS\Client\Configuration\Client Properties\NOIDMIF Directory" Else strNoIDMifRegLocation = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties\NOIDMIF Directory" End If GetMifFileDirectory = objShell.RegRead(strNoIDMifRegLocation) End Function Function GetMaxdataWarranty(strSN) ' =========================================================================================== ' Returns warranty start date for Maxdata Computers ' =========================================================================================== Dim arrReturn(1) strURL = "http://sys.maxdata.de/default.asp?action=query" strContentFull = HTTPDownload (strURL, "serial=" & strSN, "POST") intStart = instr(strContentFull, "<span style=" & chr(34) & "margin-left:10px;" & chr(34) & ">Datum:" ) strDate = Left( Right(strContentFull, (Len(strContentFull) - intStart - 38)), 10) arrReturn(0) = ConvertMaxdataDate(strDate) ' start date arrReturn(1) = "" ' end date can't recognised for Maxdata Computers GetMaxdataWarranty = arrReturn End Function Function ConvertMaxdataDate(strDate) ' =========================================================================================== ' Convert the date from dd.mm.yyyy to yyyy-mm-dd ' =========================================================================================== Datearray = split(strDate, ".", -1) strDay = Datearray(0) strMonth = Datearray(1) strYear = Datearray(2) ConvertMaxdataDate = strYear & "-" & strMonth & "-" & strDay End Function Function GetDellWarranty(strSN) ' =========================================================================================== ' Returns warranty dates for Dell Computers ' =========================================================================================== Dim arrReturn(1) strURL = "http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&~tab=1&ServiceTag=" strContentFull = HTTPDownload (strURL, strSN, "GET") strContentTable = GetDellContractsTable(strContentFull) arrRows = GetDellConstracts(strContentTable) booRowSpan = False strWarrantyBeginn = "" strWarrantyEnd = "" For i = 1 To UBound(arrRows) arrCells = GetDellConstractsCells (arrRows(i)) strWarrantyTempBeginn = ConvertDellDate(arrCells(2)) If strWarrantyBeginn = "" OR strWarrantyBeginn > strWarrantyTempBeginn Then strWarrantyBeginn = strWarrantyTempBeginn End If strWarrantyTempEnd = ConvertDellDate(arrCells(3)) If strWarrantyEnd = "" OR strWarrantyEnd < strWarrantyTempEnd Then strWarrantyEnd = strWarrantyTempEnd End If Next arrReturn(0) = strWarrantyBeginn arrReturn(1) = strWarrantyEnd GetDellWarranty = arrReturn End Function Function GetDellContractsTable(strHTML) ' =========================================================================================== ' Returns the HTML table containing all Dell contracts ' =========================================================================================== intStart = instr(UCase(strHTML), UCase( "class=" & chr(34) & "contract_table" & chr(34) )) intStart = instr(intStart, strHTML, ">") strHTML = Right (strHTML, (Len(strHTML) - intStart)) intEnd = instr(UCase(strHTML), "</TABLE>") - 1 strHTML = Left(strHTML, intEnd) GetDellContractsTable = strHTML End Function Function GetDellConstracts(strHTML) ' =========================================================================================== ' Splits the HTML table to rows containing a single Dell contract ' =========================================================================================== arrRows = Split(strHTML, "</tr><tr>", -1 , 1) For Each strRow in arrRows strRow = RTrim( LTrim(strRow) ) Next GetDellConstracts = arrRows End Function Function GetDellConstractsCells(strHTML) ' =========================================================================================== ' Splits a HTML table row to single cells ' =========================================================================================== arrCells = Split(strHTML, "</td><td", -1 , 1) For i = 0 To UBound(arrCells) intStart = instr(arrCells(i), ">") arrCells(i) = Right(arrCells(i), (Len(arrCells(i)) - intStart)) Next GetDellConstractsCells = arrCells End Function Function ConvertDellDate(strDate) ' =========================================================================================== ' Convert the date from mm/dd/yyyy to yyyy-mm-dd ' =========================================================================================== Datearray = split(strDate, "/", -1) strMonth = Datearray(0) strDay = Datearray(1) strYear = Datearray(2) If Len(strMonth) = 1 Then strMonth = "0" & strMonth End If If Len(strDay) = 1 Then strDay = "0" & strDay End If ConvertDellDate = strYear & "-" & strMonth & "-" & strDay End Function Function GetHPWarranty(strSN) ' =========================================================================================== ' Returns warranty dates for HP computers ' =========================================================================================== Dim arrReturn(1) strURL = "http://h20000.www2.hp.com/bizsupport/TechSupport/WarrantyResults.jsp?country=US&sn=" strContentFull = HTTPDownload(strURL , strSN, "GET") strContentTable = GetHPContractsTable(strContentFull) arrRows = GetHPConstracts(strContentTable) booRowSpan = False strWarrantyBeginn = "" strWarrantyEnd = "" For i = 1 To UBound(arrRows) arrCells = GetHPConstractsCells (arrRows(i)) If UBound(arrCells) = 7 OR (booRowSpan = True AND UBound(arrCells) = 6) Then If booRowSpan = True AND UBound(arrCells) = 6 Then intFirstCell = 0 Else intFirstCell = 1 strWarrantyDesc = arrCells(0) End If ' strServiceType = arrCells (intFirstCell) strWarrantyTempBeginn = arrCells (intFirstCell + 1) strWarrantyTempEnd = arrCells (intFirstCell + 2) ' strWarrantyLevel = arrCells (intFirstCell + 4) ' strWarrantyDeliverabled = arrCells (intFirstCell + 5) strRowSpan = "rowspan=" & chr(34) & "2" & chr(34) If instr(1, arrCells(0), strRowSpan, 1) > 0 Then booRowSpan = True else booRowSpan = False End If strWarrantyTempBeginn = ConvertHPDate(RemoveTDTags(strWarrantyTempBeginn)) If strWarrantyBeginn = "" OR strWarrantyBeginn > strWarrantyTempBeginn Then strWarrantyBeginn = strWarrantyTempBeginn End If strWarrantyTempEnd = ConvertHPDate(RemoveTDTags(strWarrantyTempEnd)) If strWarrantyEnd = "" OR strWarrantyEnd < strWarrantyTempEnd Then strWarrantyEnd = strWarrantyTempEnd End If End If Next arrReturn(0) = strWarrantyBeginn arrReturn(1) = strWarrantyEnd GetHPWarranty = arrReturn End Function Function ConvertHPDate(strDate) ' =========================================================================================== ' Convert the date from d MMM yyyy to yyyy-mm-dd ' =========================================================================================== strYear = Right(strDate, 4) Select Case UCase(Right( Left(strDate, 6), 3)) Case "JAN" strMonth = "01" Case "FEB" strMonth = "02" Case "MAR" strMonth = "03" Case "APR" strMonth = "04" Case "MAY" strMonth = "05" Case "JUN" strMonth = "06" Case "JUL" strMonth = "07" Case "AUG" strMonth = "08" Case "SEP" strMonth = "09" Case "OCT" strMonth = "10" Case "NOV" strMonth = "11" Case "DEC" strMonth = "12" End Select strDay = Left(strDate, 2) strDate = strYear & "-" & strMonth & "-" & strDay ConvertHPDate = strDate End Function Function RemoveTDTags(strContent) ' =========================================================================================== ' Removes unused HTML tags, tabs and spaces from table cells ' =========================================================================================== intEnd = instr(1, strContent, "</td>", 1) If IntEnd > 0 Then strContent = Left(strContent, (intEnd - 1)) End If intStart = instr(1, strContent, ">", 1) If intStart > 0 Then strContent = Right(strContent, (Len(strContent) - intStart)) End If strContent = RTrim(LTrim(strContent)) strContent = Replace (strContent, CHR(13), "", 1, -1, 1) strContent = Replace (strContent, CHR(10), "", 1, -1, 1) strContent = Replace (strContent, CHR(9), "", 1, -1, 1) RemoveTDTags = strContent End Function Sub GetBiosInfo() strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS") For each objBIOS in colBIOS Wscript.Echo "Build Number: " & objBIOS.BuildNumber Wscript.Echo "Current Language: " & objBIOS.CurrentLanguage Wscript.Echo "Installable Languages: " & objBIOS.InstallableLanguages Wscript.Echo "Manufacturer: " & objBIOS.Manufacturer Wscript.Echo "Name: " & objBIOS.Name Wscript.Echo "Primary BIOS: " & objBIOS.PrimaryBIOS Wscript.Echo "Release Date: " & objBIOS.ReleaseDate Wscript.Echo "Serial Number: " & objBIOS.SerialNumber Wscript.Echo "SMBIOS Version: " & objBIOS.SMBIOSBIOSVersion Wscript.Echo "SMBIOS Major Version: " & objBIOS.SMBIOSMajorVersion Wscript.Echo "SMBIOS Minor Version: " & objBIOS.SMBIOSMinorVersion Wscript.Echo "SMBIOS Present: " & objBIOS.SMBIOSPresent Wscript.Echo "Status: " & objBIOS.Status Wscript.Echo "Version: " & objBIOS.Version For i = 0 to Ubound(objBIOS.BiosCharacteristics) Wscript.Echo "BIOS Characteristics: " & objBIOS.BiosCharacteristics(i) Next Next End Sub Sub GetBoardInfo() ' =========================================================================================== ' Returns the serial number from BIOS ' http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/computermanagement/hardware/ ' =========================================================================================== strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard") For Each objItem in colItems Wscript.Echo "Depth: " & objItem.Depth Wscript.Echo "Description: " & objItem.Description Wscript.Echo "Height: " & objItem.Height Wscript.Echo "Hosting Board: " & objItem.HostingBoard Wscript.Echo "Hot Swappable: " & objItem.HotSwappable Wscript.Echo "Manufacturer: " & objItem.Manufacturer Wscript.Echo "Model: " & objItem.Model Wscript.Echo "Name: " & objItem.Name Wscript.Echo "Other Identifying Information: " & objItem.OtherIdentifyingInfo Wscript.Echo "Part Number: " & objItem.PartNumber Wscript.Echo "Powered On: " & objItem.PoweredOn Wscript.Echo "Product: " & objItem.Product Wscript.Echo "Removable: " & objItem.Removable Wscript.Echo "Replaceable: " & objItem.Replaceable Wscript.Echo "Requirements Description: " & objItem.RequirementsDescription Wscript.Echo "Requires DaughterBoard: " & objItem.RequiresDaughterBoard Wscript.Echo "Serial Number: " & objItem.SerialNumber Wscript.Echo "SKU: " & objItem.SKU Wscript.Echo "Slot Layout: " & objItem.SlotLayout Wscript.Echo "Special Requirements: " & objItem.SpecialRequirements Wscript.Echo "Tag: " & objItem.Tag Wscript.Echo "Version: " & objItem.Version Wscript.Echo "Weight: " & objItem.Weight Wscript.Echo "Width: " & objItem.Width Next End Sub Function GetBiosSerialNumber() ' =========================================================================================== ' Returns the serial number from Bios ' http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/computermanagement/hardware/ ' =========================================================================================== strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS") For each objBIOS in colBIOS GetBiosSerialNumber = objBIOS.SerialNumber Next End Function Function GetSerialNumber() ' =========================================================================================== ' Returns the serial number from Board ' http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/computermanagement/hardware/ ' =========================================================================================== strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard") For Each objItem in colItems GetSerialNumber = objItem.SerialNumber Next End Function Function GetBiosVersion() strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS") For each objBIOS in colBIOS GetBiosVersion = objBIOS.Version Next End Function Function GetManufacturer() ' =========================================================================================== ' Returns the manufacturer from BIOS ' http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/computermanagement/hardware/ ' =========================================================================================== strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * from Win32_BaseBoard") For Each objItem in colItems GetManufacturer = objItem.Manufacturer Next End Function Function GetHPContractsTable(strHTML) ' =========================================================================================== ' Returns the HTML table containing all HP contracts ' =========================================================================================== intStart = instr(UCase(strHTML), UCase("summary=" & chr(34) & "Add summary of the data table" & chr(34) )) intStart = instr(intStart, strHTML, ">") strHTML = Right (strHTML, (Len(strHTML) - intStart)) intEnd = instr(UCase(strHTML), "</TABLE>") - 1 strHTML = Left(strHTML, intEnd) GetHPContractsTable = strHTML End Function Function GetHPConstracts(strHTML) ' =========================================================================================== ' Splits the HTML table to rows containing a single HP contract ' =========================================================================================== arrRows = Split(strHTML, "<tr>", -1 , 1) For Each strRow in arrRows strRow = RTrim( LTrim(strRow) ) Next GetHPConstracts = arrRows End Function Function GetHPConstractsCells(strHTML) ' =========================================================================================== ' Splits a HTML table row to single cells ' =========================================================================================== strHTML = RTrim(LTRim(strHTML)) arrCells = Split(strHTML, "</td>", -1 , 1) For Each strCell in arrCells intStart = instr(strCell, ">") strCell = Right(strCell, (Len(strCell) - intStart)) strCell = RTrim( LTrim(strCell) ) Next GetHPConstractsCells = arrCells End Function Function HTTPDownload(strURL , strParams, strType) ' =========================================================================================== ' Returns html content from a webpage ' =========================================================================================== Dim i, objHTTP, strContent ' Set objHTTP = CreateObject("Microsoft.XMLHTTP") Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") If GetInternalNetwork = True Then objHTTP.SetProxy 2, "evswa01.etavis.local:8080" End If If strType = "GET" Then objHTTP.Open "GET", strURL & strParams, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.Send Else objHTTP.Open "POST", strURL, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.Send strParams End If strContent = objHTTP.responseText Set objHTTP = Nothing HTTPDownload = strContent End Function Function OldHTTPDownload(strURL , strParams, strType) ' =========================================================================================== ' Returns html content from a webpage ' =========================================================================================== Dim i, objHTTP, strContent ' Set objHTTP = CreateObject("Microsoft.XMLHTTP") Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP") If strType = "GET" Then objHTTP.Open "GET", strURL & strParams, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.Send Else objHTTP.Open "POST", strURL, False objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" objHTTP.Send strParams End If strContent = objHTTP.responseText Set objHTTP = Nothing HTTPDownload = strContent End Function Function GetInternalNetwork strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE") booReturn = False For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress) ' WScript.Echo IPConfig.IPAddress(i) If Left(IPConfig.IPAddress(i), 6) = "10.41." Then booReturn = True Exit For End If Next End If Next GetInternalNetwork = booReturn End Function
After using this vbscript on each client computer you can create a SCCM report to list the warranty informations.
Hi, I get the following error in your script, running on a HP EliteBook 8460p
C:\>cscript warrantyinfo.vbs
Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.
C:\warrantyinfo.vbs(460, 2) Microsoft VBScript runtime error: Invalid procedure call or argument: ‘instr’
C:\>
The script was downloaded as is and was renamed to .vbs and not modified in any way.
Sorry, i corrected. You can download the script again and use it.
Hi, it is me again.
Just to let you know, DELL has changed their Warranty Status site!
Could you update your script to work with the new site please?
This is really interesting, You’re a very skilled blogger. I have joined your feed and look forward to seeking more of your great post. Also, I have shared your website in my social networks!
ӏt’s nearly impossible to find knowledgeable people on this subject, however, you seem like you know what you’re talking аbout!
Thanks