This VBS script will read a text file called MachineList.Txt and will write all of the SMS services information to an excel spreadsheet. If the service state is stopped the results will be written in red.
VBS Script:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
objExcel.Cells(1, 1).Value = "Machine Name"
objExcel.Cells(1, 2).Value = "Service Name"
objExcel.Cells(1, 3).Value = "Current State"
servicename = "SMS_"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Service Where Name Like '" & servicename & "%'")
For Each objItem in colItems
objExcel.Cells(intRow, 1).Value = objItem.SystemName
objExcel.Cells(intRow, 2).Value = objItem.DisplayName
objExcel.Cells(intRow, 3).Value = objItem.State
If objExcel.Cells(intRow, 3).Value = "Stopped" Then
objExcel.Cells(intRow, 3).Font.ColorIndex = 3
End If
intRow = intRow + 1
Next
Loop
objExcel.Range("A1:C1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
No Comments