VBS Script To Retrieve A List Of Machines Adapter Link Speeds

 

This VBS script will take a list of machine names from a text file called MachineList.Txt and write the Machine name, adapter name, whether or not it is active and return the link speed(s) in KB or MB per second as needed 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 = "Name"

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

objExcel.Cells(1, 4).Value = "Speed"

 

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\Wmi")

Set colItems = objWMIService.ExecQuery("Select * From MSNdis_LinkSpeed")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

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

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

If objItem.NdisLinkSpeed < 10000 Then

strNICSpeed = objItem.NdisLinkSpeed / 10 & " KBps"

ElseIf objItem.NdisLinkSpeed > 10000 Then

strNICSpeed = objItem.NdisLinkSpeed / 10000 & " MBps"

End If

objExcel.Cells(intRow, 4).Value = strNICSpeed

intRow = intRow + 1

Next

Loop

 

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

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

 

Published Sunday, June 24, 2007 8:23 AM by dhite
Filed under:

Comments

No Comments