VBS Script To Send Network Adapter Information To Excel From A List Of Machines

 

This VBS script will read a text file called MachineList.Txt and will write the Machine name, Network adapter name and Manufacturer name to an Excel spreadsheet.

 

VBS Script:

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Network Adapter"

objExcel.Cells(1, 3).Value = "Manufacturer"

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapter Where NetConnectionStatus = '2'")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = objItem.SystemName

objExcel.Cells(intRow, 2).Value = objItem.Name

objExcel.Cells(intRow, 3).Value = objItem.Manufacturer

intRow = intRow + 1

Next

 

objExcel.Range("A1:C1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

loop

 

Wscript.Echo "Done"

 

 

Published Sunday, October 26, 2008 2:34 PM by dhite
Filed under:

Comments

No Comments