{"id":384,"date":"2011-01-17T14:33:59","date_gmt":"2011-01-17T20:33:59","guid":{"rendered":"http:\/\/www.anthonyreinke.com\/?p=384"},"modified":"2018-05-07T21:19:51","modified_gmt":"2018-05-08T03:19:51","slug":"information-gathering-on-my-own-servers","status":"publish","type":"post","link":"https:\/\/anthonyreinke.com\/index.php\/2011\/01\/17\/information-gathering-on-my-own-servers\/","title":{"rendered":"Information Gathering on My Own Servers"},"content":{"rendered":"<p>Currently I am having an issue with not knowing information about the servers I am responsible. \u00a0 I am not happy not knowing things. \u00a0I spent a little time gather different parts of different scripts (hacker \/ script kiddie style) and compiling them in to one Visual Basic Script. \u00a0This script is designed to work against Dell Servers. \u00a0It 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. \u00a0It takes the list of servers from &#8220;hosts.txt&#8221; which is just a list of servers or ip addresses where there is one per line. \u00a0It will write all the information it gathers in to a file called &#8220;report.txt&#8221;.<\/p>\n<p>Download the <a href=\"http:\/\/www.anthonyreinke.com\/repository\/SystemInfo.vbs\">.VBS File<\/a><\/p>\n<p>Here is the code:<\/p>\n<blockquote>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Option Explicit<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim url, svctag, wshShell, wshNetwork<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim strComputer, colGroups, objGroup, objUser<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim objWMIService, colItems, objItem<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim warrantyRows, warrantyCols<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim objsvc,svccount, errorChecking,svc,objNetwork,colAccounts<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim get_OS_Bit, info, strComputer2, oReg, strKeyPath, strValueName, strValue<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim objShell, objIE, objWMI<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim colOSes, objOS<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim objFSO, objTextFile, objTextFileW, objTextFileO, strNextLine, arrServiceList<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Dim i, result<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Const ForReading = 1<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Const ForAppending = 8<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objTextFileW = objFSO.OpenTextFile (&#8220;report.txt&#8221;, ForAppending, True)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objFSO = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objTextFileO = objFSO.OpenTextFile _<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">(&#8220;hosts.txt&#8221;, ForReading)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Do Until objTextFileO.AtEndOfStream<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">strNextLine = objTextFileO.Readline<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">arrServiceList = Split(strNextLine , &#8220;,&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">strComputer = arrServiceList(0)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">wscript.echo strComputer<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">On Error Resume Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set colOSes = objWMIService.ExecQuery(&#8220;Select * from Win32_OperatingSystem&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">For Each objOS in colOSes<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;########################################&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;== \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Computer Info \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ==&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Computer Name \u00a0 \u00a0 \u00a0: &#8221; &amp; objOS.CSName<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objWMI = GetObject(&#8220;winmgmts:\\&#8221; &amp; strComputer &amp; &#8220;rootCIMV2&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set colItems = objWMI.ExecQuery(&#8220;SELECT * FROM Win32_OperatingSystem&#8221;,,48)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">For Each objItem in colItems<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Operating System \u00a0 : &#8221; &amp; objItem.Caption<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;OS Version Number \u00a0: &#8221; &amp; objItem.Version<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Service Pack \u00a0 \u00a0 \u00a0 : &#8221; &amp; objItem.ServicePackMajorVersion<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">const HKEY_LOCAL_MACHINE = &amp;H80000002<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set oReg=GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\&#8221; &amp; strComputer &amp; &#8220;rootdefault:StdRegProv&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">strKeyPath = &#8220;HARDWAREDESCRIPTIONSystemCentralProcessor\ufffd&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">strValueName = &#8220;Identifier&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">if (instr(strValue,&#8221;x86&#8243;)) then<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">get_OS_Bit=&#8221;32&#8243;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">elseif (instr(strValue,&#8221;64&#8243;)) then<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">get_OS_Bit=&#8221;64&#8243;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">else<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">get_OS_Bit=&#8221;NotSure&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">end if<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;OS is \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0: &#8221; &amp; get_OS_Bit &amp; &#8220;bit&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;== \u00a0Get the Dell warranty information ==&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">url = &#8220;http:\/\/support.dell.com\/support\/topics\/global.aspx\/support\/my_systems_info\/details?c=us&amp;cs=RC956904&amp;l=en&amp;s=hied&amp;~lt=bodyonly&amp;~wsf=tabs&amp;servicetag=&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">set objIE=createobject(&#8220;internetexplorer.application&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">set objShell = WScript.CreateObject(&#8220;WScript.Shell&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">set objWMI = GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}!\\&#8221; &amp; strComputer &amp; &#8220;rootcimv2&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">If InStr(UCase(objWMI.ExecQuery(&#8220;Select Manufacturer From Win32_ComputerSystem&#8221;).ItemIndex(0).Manufacturer), &#8220;DELL&#8221;) = 0 then Err.Raise 2, &#8220;This is not a Dell dude!&#8221;, &#8220;No Service Tag&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">svctag = objWMI.ExecQuery \u00a0(&#8220;Select SerialNumber from Win32_BIOS&#8221;).ItemIndex(0).SerialNumber<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objWMIService = GetObject(&#8220;winmgmts:&#8221; _<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">&amp; &#8220;{impersonationLevel=impersonate}!\\&#8221; _<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">&amp; strComputer &amp; &#8220;rootcimv2&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Service Tag \u00a0 \u00a0 \u00a0 \u00a0: &#8221; &amp; svctag<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objIE.navigate url &amp; svctag<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">do while objIE.readystate&lt;&gt;4 : wscript.sleep 50 : loop<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">set warrantyRows = objIE.document.getElementsByTagName(&#8220;table&#8221;).item(1).getElementsByTagName(&#8220;table&#8221;).item(122).getElementsByTagName(&#8220;table&#8221;).item(0).getElementsByTagName(&#8220;tr&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">For i = 1 to warrantyRows.length &#8211; 1<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">set warrantyCols = warrantyRows.item(i).getElementsByTagName(&#8220;td&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Description \u00a0 \u00a0 \u00a0 \u00a0: &#8221; &amp; warrantyCols.item(0).innerText<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Provider \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 : &#8221; &amp; warrantyCols.item(1).innerText<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Warranty Extension : &#8221; &amp; warrantyCols.item(122).innerText<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Start Date \u00a0 \u00a0 \u00a0 \u00a0 : &#8221; &amp; warrantyCols.item(3).innerText<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;End Date \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 : &#8221; &amp; warrantyCols.item(4).innerText<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Days Left \u00a0 \u00a0 \u00a0 \u00a0 \u00a0: &#8221; &amp; warrantyCols.item(5).innerText<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;== \u00a0 \u00a0 \u00a0 List all local users \u00a0 \u00a0 \u00a0 \u00a0 ==&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set objNetwork = CreateObject(&#8220;Wscript.Network&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">&#8216;strComputer = objNetwork.ComputerName<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set colAccounts = GetObject(&#8220;WinNT:\/\/&#8221; &amp; strComputer &amp; &#8220;&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">colAccounts.Filter = Array(&#8220;user&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">For Each objUser In colAccounts<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Local User \u00a0 \u00a0 \u00a0 \u00a0 : &#8221; &amp; objUser.Name<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;===========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;== List all local groups and their users ==&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Writeline &#8220;===========================================&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Set colGroups = GetObject(&#8220;WinNT:\/\/&#8221; &amp; strComputer &amp; &#8220;&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">colGroups.Filter = Array(&#8220;group&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">For Each objGroup In colGroups<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Group \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0: &#8221; &amp; objGroup.Name<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">For Each objUser in objGroup.Members<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;User \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 : &#8221; &amp; objUser.Name<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;== List all services ==&#8221;<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">set objsvc = GetObject(&#8220;winmgmts:{impersonationLevel=impersonate}\\&#8221; &amp; strComputer &amp; &#8220;rootcimv2&#8221;).ExecQuery (&#8220;SELECT * FROM Win32_Service&#8221;)<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">for each svc in objsvc<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Service \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0: &#8221; &amp; svc.displayname<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Current Status \u00a0 \u00a0 : &#8221; &amp; svc.state<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Startus Type \u00a0 \u00a0 \u00a0 : &#8221; &amp; svc.startmode<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine &#8220;Run Server As \u00a0 \u00a0 \u00a0: &#8221; &amp; svc.startname<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">next<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.WriteLine<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">Loop<\/span><\/div>\n<div id=\"_mcePaste\"><span style=\"color: #339966;\">objTextFileW.Close<\/span><\/div>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Currently I am having an issue with not knowing information about the servers I am responsible. \u00a0 I am not happy not knowing things. \u00a0I spent a little time gather different parts of different scripts (hacker \/ script kiddie style) and compiling them in to one Visual Basic Script. \u00a0This script is designed to work [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-384","post","type-post","status-publish","format-standard","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/comments?post=384"}],"version-history":[{"count":1,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/384\/revisions"}],"predecessor-version":[{"id":12417,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/384\/revisions\/12417"}],"wp:attachment":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/media?parent=384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/categories?post=384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/tags?post=384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}