This script will grab the warranty end date based on a server’s/laptop’s/PC’s asset tag number and then, it will create a file on your C drive named warranty.txt
You can modify the behaviour as needed. Just create a new file and put the code in it, then rename it to warrantycheck.vbs.
This is usefull for massive checks on servers and workstation or Labtech automation
- 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/JigsawWebServices/""> <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/jigsawwebservices/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 Dell malaka"
- svctag = Trim(objWMI.ExecQuery ("Select SerialNumber from Win32_BIOS").ItemIndex(0).SerialNumber)
- SoapRequest = Replace(SoapRequest, "!SERVICETAG!", svctag)
- Set objHTTP = CreateObject("Msxml2.XMLHTTP")
- objHTTP.open "POST", URL, false
- objHTTP.setRequestHeader "Content-Type", "text/xml"
- objHTTP.setRequestHeader "SOAPAction", "http://support.dell.com/JigsawWebServices/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
- Set NodeList = objXML.SelectNodes("//Asset/Entitlements/EntitlementData")
- set warrantyCols = NodeList.item(0)
- dim filesys, filetxt, getname, path
- Set filesys = CreateObject("Scripting.FileSystemObject")
- Set filetxt = filesys.CreateTextFile("c:\warranty.txt", True)
- path = filesys.GetAbsolutePathName("c:\warranty.txt")
- getname = filesys.GetFileName(path)
- filetxt.WriteLine(Mid(warrantyCols.SelectSingleNode("EndDate").text,1,10) & " (" & svctag & ")")
- filetxt.Close