Currently I am having an issue with not knowing information about the servers I am responsible. I am not happy not knowing things. I spent a little time gather different parts of different scripts (hacker / script kiddie style) and compiling them in to one Visual Basic Script. This script is designed to work against Dell Servers. It will ask the computer for it name, the OS, OS version number, Service Packs, Bit Level (32 or 64 bit), Dell Warranty info, list of local users, and a list of local groups and the users in the groups. It takes the list of servers from “hosts.txt” which is just a list of servers or ip addresses where there is one per line. It will write all the information it gathers in to a file called “report.txt”.
Download the .VBS File
Here is the code:
Option ExplicitDim url, svctag, wshShell, wshNetworkDim strComputer, colGroups, objGroup, objUserDim objWMIService, colItems, objItemDim warrantyRows, warrantyColsDim objsvc,svccount, errorChecking,svc,objNetwork,colAccountsDim get_OS_Bit, info, strComputer2, oReg, strKeyPath, strValueName, strValueDim objShell, objIE, objWMIDim colOSes, objOSDim objFSO, objTextFile, objTextFileW, objTextFileO, strNextLine, arrServiceListDim i, resultConst ForReading = 1Const ForAppending = 8Set objFSO = CreateObject(“Scripting.FileSystemObject”)Set objTextFileW = objFSO.OpenTextFile (“report.txt”, ForAppending, True)Set objFSO = CreateObject(“Scripting.FileSystemObject”)Set objTextFileO = objFSO.OpenTextFile _(“hosts.txt”, ForReading)Do Until objTextFileO.AtEndOfStreamstrNextLine = objTextFileO.ReadlinearrServiceList = Split(strNextLine , “,”)strComputer = arrServiceList(0)wscript.echo strComputerOn Error Resume NextSet colOSes = objWMIService.ExecQuery(“Select * from Win32_OperatingSystem”)For Each objOS in colOSesobjTextFileW.Writeline “########################################”objTextFileW.WritelineobjTextFileW.Writeline “========================================”objTextFileW.Writeline “== Computer Info ==”objTextFileW.Writeline “========================================”objTextFileW.WriteLine “Computer Name : ” & objOS.CSNameNextobjTextFileW.WriteLineSet objWMI = GetObject(“winmgmts:\” & strComputer & “rootCIMV2”)Set colItems = objWMI.ExecQuery(“SELECT * FROM Win32_OperatingSystem”,,48)For Each objItem in colItemsobjTextFileW.WriteLine “Operating System : ” & objItem.CaptionobjTextFileW.WriteLine “OS Version Number : ” & objItem.VersionobjTextFileW.WriteLine “Service Pack : ” & objItem.ServicePackMajorVersionobjTextFileW.WriteLineNextconst HKEY_LOCAL_MACHINE = &H80000002Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strComputer & “rootdefault:StdRegProv”)strKeyPath = “HARDWAREDESCRIPTIONSystemCentralProcessor�”strValueName = “Identifier”oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValueif (instr(strValue,”x86″)) thenget_OS_Bit=”32″elseif (instr(strValue,”64″)) thenget_OS_Bit=”64″elseget_OS_Bit=”NotSure”end ifobjTextFileW.WriteLine “OS is : ” & get_OS_Bit & “bit”objTextFileW.WriteLineobjTextFileW.Writeline “========================================”objTextFileW.WriteLine “== Get the Dell warranty information ==”objTextFileW.Writeline “========================================”url = “http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&cs=RC956904&l=en&s=hied&~lt=bodyonly&~wsf=tabs&servicetag=”set objIE=createobject(“internetexplorer.application”)set objShell = WScript.CreateObject(“WScript.Shell”)set objWMI = GetObject(“winmgmts:{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2”)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 = objWMI.ExecQuery (“Select SerialNumber from Win32_BIOS”).ItemIndex(0).SerialNumberSet objWMIService = GetObject(“winmgmts:” _& “{impersonationLevel=impersonate}!\” _& strComputer & “rootcimv2”)objTextFileW.WriteLine “Service Tag : ” & svctagobjIE.navigate url & svctagdo while objIE.readystate<>4 : wscript.sleep 50 : loopset warrantyRows = objIE.document.getElementsByTagName(“table”).item(1).getElementsByTagName(“table”).item(122).getElementsByTagName(“table”).item(0).getElementsByTagName(“tr”)For i = 1 to warrantyRows.length – 1set warrantyCols = warrantyRows.item(i).getElementsByTagName(“td”)objTextFileW.WriteLine “Description : ” & warrantyCols.item(0).innerTextobjTextFileW.WriteLine “Provider : ” & warrantyCols.item(1).innerTextobjTextFileW.WriteLine “Warranty Extension : ” & warrantyCols.item(122).innerTextobjTextFileW.WriteLine “Start Date : ” & warrantyCols.item(3).innerTextobjTextFileW.WriteLine “End Date : ” & warrantyCols.item(4).innerTextobjTextFileW.WriteLine “Days Left : ” & warrantyCols.item(5).innerTextobjTextFileW.WriteLineNextobjTextFileW.Writeline “========================================”objTextFileW.WriteLine “== List all local users ==”objTextFileW.Writeline “========================================”Set objNetwork = CreateObject(“Wscript.Network”)‘strComputer = objNetwork.ComputerNameSet colAccounts = GetObject(“WinNT://” & strComputer & “”)colAccounts.Filter = Array(“user”)For Each objUser In colAccountsobjTextFileW.WriteLine “Local User : ” & objUser.NameNextobjTextFileW.WriteLineobjTextFileW.Writeline “===========================================”objTextFileW.WriteLine “== List all local groups and their users ==”objTextFileW.Writeline “===========================================”Set colGroups = GetObject(“WinNT://” & strComputer & “”)colGroups.Filter = Array(“group”)For Each objGroup In colGroupsobjTextFileW.WriteLine “Group : ” & objGroup.NameFor Each objUser in objGroup.MembersobjTextFileW.WriteLine “User : ” & objUser.NameNextobjTextFileW.WriteLineNextobjTextFileW.WriteLine “== List all services ==”set objsvc = GetObject(“winmgmts:{impersonationLevel=impersonate}\” & strComputer & “rootcimv2”).ExecQuery (“SELECT * FROM Win32_Service”)for each svc in objsvcobjTextFileW.WriteLine “Service : ” & svc.displaynameobjTextFileW.WriteLine “Current Status : ” & svc.stateobjTextFileW.WriteLine “Startus Type : ” & svc.startmodeobjTextFileW.WriteLine “Run Server As : ” & svc.startnameobjTextFileW.WriteLinenextobjTextFileW.WriteLineLoopobjTextFileW.Close
[…] January 17th, 2011 I wrote about a script I wrote to gather information on my network (http://www.anthonyreinke.com/?p=384). I ran the scan a few time with a lot of errors. Â The issues were due to the different domains. […]
Cool script but on my end the output is blank for Service Tag.
I also have another problem. For some reason every server reports the same tag info. When I launch the support website I have a static service tag and that infomation keeps coming up over and over into the script.. All attempts to clear the browser cache fails.. any ideas?
I ran in to issues like this also. The main issue I ran in to was we have multiple domains and there isn’t a single login that works on all domains (by design). I ended up using LanSweeper (http://www.lansweeper.com/). I was able to give the application multiple logins to try. It was able to pull all the info I needed plus some. You can make custom reports or use their built in reports. What is even better is that since it is database driven, I can run reports and queries from other tools.