This VBS script will take a list of Distribution Point (DP) servers from a text file called DPServers.Txt and will write the SMS Agent Host status for each server to an excel spreadsheet.
VBS Script:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("DPServers.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 Agent Host"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_Service Where DisplayName = '" & 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