• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
'*********************************************************************************'Script to remotely inventory installed services from a list of machines from a' text file, put the services into an Excel workbook, and then save the' workbook to the desktop.' Created by: Brian Bohanon' Created: 6/17/2008'*********************************************************************************Option ExplicitDim arrFileLines()Dim tstDim i, j, k, lDim objFSO, objFile, objDialog, objExcel, objWMIService, objService, objWorkbookDim WshShellDim colServicesDim srcFileName'source fileDim intResultDim strComputer'computer to inventory'ConstantsConst xlLeft = -4131Const xlHorizontal = -4128'Set ObjectsSet objExcel = CreateObject("Excel.Application")Set objDialog = CreateObject("UserAccounts.CommonDialog")Set WshShell = WScript.CreateObject("WScript.Shell")'Open the source file that contains the list of computersobjDialog.Filter = "Text Files|*.txt"objDialog.InitialDir = WshShell.SpecialFolders("Desktop")intResult = objDialog.ShowOpen If intResult = 0 ThenWscript.QuitElse'Set selected file to srcFileNamesrcFileName = objDialog.FileNamei = 0Set objFSO = CreateObject("Scripting.FileSystemObject")Set objFile = objFSO.OpenTextFile(srcFileName, 1)Do Until objFile.AtEndOfStreamRedim Preserve arrFileLines(i)arrFileLines(i) = objFile.ReadLinei = i + 1LoopobjFile.Close'*********************************************************************************' Create a new Excel Workboot'*********************************************************************************objExcel.Visible = TrueSet objWorkbook = objExcel.Workbooks.Add()'*********************************************************************************'Loop through the array of computers, create a worksheet with the computer name,
 
' get the list of services,' and write out the services to the excel sheet'*********************************************************************************k = 3objExcel.Worksheets("Sheet1").DeleteobjExcel.Worksheets("Sheet2").DeleteFor l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1On Error Resume Nextif k = 3 thenobjExcel.Worksheets("Sheet" & k).ActivateobjExcel.Worksheets("Sheet" & k).Name = arrFileLines(l)elseobjExcel.Worksheets.AddobjExcel.Worksheets("Sheet" & k).ActivateobjExcel.Worksheets("Sheet" & k).Name = arrFileLines(l)end if'*********************************************************************************'Services Information'*********************************************************************************'Select server to inventorySet objWMIService = GetObject("winmgmts:\\" & arrFileLines(l) &"\root\cimv2")Set colServices = objWMIService.ExecQuery("Select * FromWin32_Service")i = 1j = 1'Column headersobjExcel.Cells(i, j).Value = "Service"objExcel.Cells(i, j).Font.Bold = TRUEj = j + 1objExcel.Cells(i, j).Value = "Status"objExcel.Cells(i, j).Font.Bold = TRUEj = j + 1objExcel.Cells(i, j).Value = "Start Mode"objExcel.Cells(i, j).Font.Bold = TRUEj = j + 1objExcel.Cells(i, j).Value = "Start Name"objExcel.Cells(i, j).Font.Bold = TRUEj = j + 1objExcel.Cells(i, j).Value = "Path Name"objExcel.Cells(i, j).Font.Bold = TRUE'Services dataFor Each objService in colServicesi = i + 1j = 1objExcel.Cells(i, j) = objService.Namej = j + 1objExcel.Cells(i, j) = objService.Statej = j + 1objExcel.Cells(i, j) = objService.StartModej = j + 1
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...