' Listing 1: The Main Loop For Each arItem In aray Err.Clear PBL = False ' ******* BEGIN CALLOUT A ******* If Len(arItem) <> 0 Then ' Test for blanks in input list. Computer = arItem XL.Sheets.Add.Name = arItem XL.Cells.Select With XL.Selection.Font .Name = "Courier New" .Size = 8 End With XL.Range("A1").Select Row = 1 : Col = 2 ' ******* END CALLOUT A ******* ' ******* BEGIN CALLOUT B ******* Set Reg = GetObject("winmgmts:\\" & Computer & _ "\root\default:StdRegProv") If Err.Number <> 0 Then XL.Cells(Row,1).Value = Computer XL.Cells(Row,2).Value = "Error.... " & Err.Number & " " _ & Err.Description If Err.Number = 462 Then ' The server is unreachable. XL.ActiveWorkbook.Sheets(computer).Tab.ColorIndex = _ UNREACHABLE ' Magenta (color index number 7) End If ServerAlerts.Add _ computer,XL.ActiveWorkbook.Sheets(computer).Tab.ColorIndex Row = Row + 1 : Col = 2 Err.Clear ' ******* END CALLOUT B ******* Else ' ******* BEGIN CALLOUT C ******* Reg.EnumValues HKEY_LOCAL_MACHINE, SKP, ValueNames, _ ValueTypes For I = 0 To UBound(ValueNames) If Err.Number = 13 Then ' No elements will cause a mismatch error. XL.Cells(Row,Col).Value = "No ValidCommunities" : Row = Row + 1 Err.Clear Else XL.Cells(Row,1).Value = "ValidCommunity" XL.Cells(Row,Col).Value = ValueNames(I) : Row = Row + 1 If Ucase(ValueNames(I)) = "PUBLIC" Or _ Ucase(ValueNames(I)) = "PRIVATE" Then PBL = True End If ' ******* END CALLOUT C ******* ' ******* BEGIN CALLOUT D ******* Select Case ValueTypes(I) Case REG_SZ ' String data type Reg.GetStringValue HKEY_LOCAL_MACHINE,SKP, _ ValueNames(I),SValue XL.Cells(Row,Col).Value = SValue : Row = Row + 1 Case REG_EXPAND_SZ ' Expandable String data type Reg.GetExpandedStringValue HKEY_LOCAL_MACHINE,SKP, _ ValueNames(I),XValue XL.Cells(Row,Col).Value = XValue : Row = Row + 1 Case REG_BINARY ' Binary data type Reg.GetBinaryValue HKEY_LOCAL_MACHINE,SKP, _ ValueNames(I),BValue binval = "" For Each bin In BValue If Len(Hex(bin)) < 2 Then binval = binval & "0" & Hex(bin) & " " Else binval = binval & Hex(bin) & " " End If Next XL.Cells(Row,Col).Value = Binval : Row = Row + 1 Case REG_DWORD ' DWORD data type Reg.GetDWORDValue HKEY_LOCAL_MACHINE,SKP, _ ValueNames(I),DValue XL.Cells(Row-1,Col+1).Value = CommunityRights(DValue) Case REG_MULTI_SZ ' Multi-String data type Reg.GetMultiStringValue HKEY_LOCAL_MACHINE,SKP,_ ValueNames(I),MValue XL.Cells(Row,Col).Value = MValue : Row = Row + 1 End Select ' ******* END CALLOUT D ******* End If Next Row = Row + 1 ' ******* BEGIN CALLOUT E ******* strService = "SNMP" checkSNMP ' ******* END CALLOUT E ******* Summary Set objWMIService = nothing ' ******* BEGIN CALLOUT F ******* ServerAlerts.Add _ computer,XL.ActiveWorkbook.Sheets(computer).Tab.ColorIndex ' ******* END CALLOUT F ******* XL.Cells.EntireColumn.AutoFit XL.Columns("A:A").Select XL.Selection.ColumnWidth = 20 XL.Columns("C:C").Select XL.Selection.ColumnWidth = 18 XL.Range("A1").Select End If Err.Clear End If Next