Jump to content

Recommended Posts

Posted

Hi Geeks!

 

Im looking for a script that I can run that will show me the network speed on each pc in the domain. I would like the output to be

 

===========

Computer 1

===========

Speed = 100mbs

 

 

===========

Computer 2

===========

Speed = 1gbs

 

 

etc etc.

 

I have zero experience with scripts and was wondering if anyone has something like this.

 

i have looked at the MS script repository and found a few examples but none of them seem to work.

 

Any help would be much appreciated.

 

James

Posted (edited)

I will have a look at this later as not much time now, I think Arthur or someone will post back with a powershell script but I will look at doing this in vbs myself as still not had time to get into or my head around powershell.

 

Also have you got a unc path that all machines have access to in terms of read / write so that the script can append data for each computer or each computer will create its own text file and each file will be named with the computer name ??

 

for example

 

computer1.txt

computer2.txt

etc

Edited by mac_shinobi
  • Thanks 1
Posted

BGInfo can do this or alternatively, if you use HP switches for example on the switch itself or via a web interface (if managed) will tell you the speed each port is operating at.

 

If you need to know what each workstation is connecting at, I would recommend BGInfo. You can also display other information, such as the IP address, Service Pack version or even create your own custom entries.

  • Thanks 2
Posted

ok, thanks guys.

 

i like bginfo but i dont want to have to physically go to each machine to see the speed. I would like it in a text file that I can see from my desk.

 

i would like the computers to modify one text document, I dont want 100 different documetns to look through.

Posted

Ok, the first script works graet but how do i combine the two??

 

strComputer = "."

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

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

For Each objItem in colItems

Wscript.Echo "InstanceName: " & objItem.InstanceName

Wscript.Echo "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10 & " kbps"

Wscript.Echo " "

Next

 

This is what im using, how do i get it into a txt file??

Posted
Ok, the first script works graet but how do i combine the two??

 

 

 

This is what im using, how do i get it into a txt file??

 

Should be able to do it like:

 

Dim Stuff, myFSO, WriteStuff, dateStamp

dateStamp = Date()

 

Stuff = ""

Stuff2 = ""

 

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set WriteStuff = myFSO.OpenTextFile("yourtextfile.txt", 8, True)

 

strComputer = "."

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

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

For Each objItem in colItems

'''''''''''''''''''''''''''''''''''''''''''''''''''''''

Stuff = "InstanceName: " & objItem.InstanceName

Stuff2 = "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10 & " kbps"

WriteStuff.WriteLine(Stuff)

WriteStuff.WriteLine(Stuff2)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''

Next

 

WriteStuff.Close

SET WriteStuff = NOTHING

SET myFSO = NOTHING

 

 

Basically just changing your echo lines to write to the file instead. Might need a little tinkering for file names etc etc :p

 

Steve

  • Thanks 1
Posted

thats works great, thaks steve. to take it a step further, how would i include the computer name in the results and only those network adapters that are connected instead of all the network adapters that are on my computer??

 

i know im asking alot here, but it will help me.

Posted

Assuming that first one I posted works (Can't test atm)

 

Try this for Comp name:

 

Dim Stuff, myFSO, WriteStuff, dateStamp

dateStamp = Date()

 

Stuff = ""

Stuff2 = ""

Stuff3 = ""

 

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set WriteStuff = myFSO.OpenTextFile("yourtextfile.txt", 8, True)

 

strComputer = "."

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

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

For Each objItem in colItems

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''

Stuff = "InstanceName: " & objItem.InstanceName

Stuff2 = "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10 & " kbps"

Stuff3 = "Computer Name: " & objItem.Name

WriteStuff.WriteLine(Stuff)

WriteStuff.WriteLine(Stuff2)

WriteStuff.WriteLine(Stuff3)

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''

Next

 

WriteStuff.Close

SET WriteStuff = NOTHING

SET myFSO = NOTHING

  • Thanks 1
Posted

Try:

 

Dim Stuff, myFSO, WriteStuff, dateStamp

dateStamp = Date()

 

Stuff = ""

Stuff2 = ""

Stuff3 = ""

 

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set WriteStuff = myFSO.OpenTextFile("yourtextfile.txt", 8, True)

 

strComputer = "."

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

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

For Each objItem in colItems

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''

Stuff = "InstanceName: " & objItem.InstanceName

Stuff2 = "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10 & " kbps"

Stuff3 = "Computer Name: " & objItem.ComputerName

WriteStuff.WriteLine(Stuff)

WriteStuff.WriteLine(Stuff2)

WriteStuff.WriteLine(Stuff3)

'''''''''''''''''''''''''''''''''''''''''''''''''' '''''

Next

 

WriteStuff.Close

SET WriteStuff = NOTHING

SET myFSO = NOTHING

 

Can't run scripts where I'm logged, so slower this way :p But try that one. Think I named "Name" wrong in first one.

Posted
error line 18: object doesnt support this property or method: 'objitem.computer name

 

 

 

Silly question, but did you put a space in it?

 

"'objitem.computer name " <- or is that just how it reported it

 

Steve

Posted

Ah, I was being stupid.

 

Dim Stuff, myFSO, WriteStuff, dateStamp

dateStamp = Date()

 

Stuff = ""

Stuff2 = ""

Stuff3 = ""

 

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set WriteStuff = myFSO.OpenTextFile("yourtextfile.txt", 8, True)

 

strComputer = "."

 

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

 

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

 

For Each objItem in colItems

Stuff3 = "Computer Name: " & objItem.Name

WriteStuff.WriteLine(Stuff3)

Next

 

 

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

 

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

For Each objItem in colItems

 

 

Stuff = "InstanceName: " & objItem.InstanceName

Stuff2 = "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10 & " kbps"

 

WriteStuff.WriteLine(Stuff)

WriteStuff.WriteLine(Stuff2)

 

 

Next

 

WriteStuff.Close

SET WriteStuff = NOTHING

SET myFSO = NOTHING

 

 

Should work now ;P

 

Only selected info from MSNdis_LinkSpeed, forgot Win32 for computer name :p

 

Try that and gimme a shout,

 

Steve

  • Thanks 1
Posted

brilliant!!

 

Thats works with the computer name.

this is the current output.

 

Computer Name: ICT-03

InstanceName: Broadcom NetXtreme 57xx Gigabit Controller

NdisLinkSpeed: 1000 mbps

InstanceName: WAN Miniport (IP)

NdisLinkSpeed: 0.0288 mbps

InstanceName: WAN Miniport (IP) - Packet Scheduler Miniport

NdisLinkSpeed: 0.0288 mbps

InstanceName: Broadcom NetXtreme 57xx Gigabit Controller - Packet Scheduler Miniport

NdisLinkSpeed: 1000 mbps

 

How do I get rid of all the other unneccesary network connections. All i want to know is the main one.

Posted

I believe this should do it, tried to comment code a bit too :p Minds playing games on me, but think I worked out mbps/mbps right.

 

Anyone below 1mb should get cut off, aka only "main" connections

 

 

'Define Variables for script

Dim NetName, NetSpeed, CompName, myFSO, WriteNetName

 

'Default Blank the variables

NetName = ""

NetSpeed = ""

CompName = ""

 

'Set File Links

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set WriteNetName = myFSO.OpenTextFile("yourtextfile.txt", 8, True)

 

'Sets Computer Name/IP

strComputer = "."

 

'Links into Win32 system for information

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

 

'Scans data for Computer Name Information

For Each objItem in colItems

CompName = "Computer Name: " & objItem.Name

WriteNetName.WriteLine(CompName)

Next

 

'Links into MSNDis_Linkspeed for information

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

 

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

 

'Scans data for Net Speed and Name

For Each objItem in colItems

 

'Removes "slow/unused links"

if objItem.NdisLinkSpeed/10 > 1000 then

 

NetName = "InstanceName: " & objItem.InstanceName

 

If objItem.NdisLinkSpeed/10 > 10000 Then

NetSpeed = "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10000 & " Mbps"

Elseif objItem.NdisLinkSpeed/10 > 1000 then

NetSpeed = "NdisLinkSpeed: " & objItem.NdisLinkSpeed/10 & " kbps"

End If

 

 

 

 

'Writes data to file

WriteNetName.WriteLine(NetName)

WriteNetName.WriteLine(NetSpeed)

 

else

'Fall out clause for "non-used" connections

end if

 

 

Next

 

'closes Links and Resets items

WriteNetName.Close

SET WriteNetName = NOTHING

SET myFSO = NOTHING

 

 

See how it goes!

Posted

aka:

 

Gives me

 

Computer Name: ICTTECH-01

InstanceName: Intel® 82567LM-3 Gigabit Network Connection

NdisLinkSpeed: 1000 Mbps

 

instead of:

 

InstanceName: Intel® 82567LM-3 Gigabit Network Connection

NdisLinkSpeed: 1000000 kbps

InstanceName: WAN Miniport (Network Monitor)

NdisLinkSpeed: 115.2 kbps

InstanceName: WAN Miniport (IP)

NdisLinkSpeed: 115.2 kbps

InstanceName: WAN Miniport (IPv6)

NdisLinkSpeed: 115.2 kbps

InstanceName: RAS Async Adapter

NdisLinkSpeed: 28.8 kbps

Posted

just thinking out loud here would it be better/possible to ditch the "InstanceName: " etc and the caridge returns and just output for example

 

pc1,VIA Rhine II Fast Ethernet Adapter,100 Mbps,VIA Rhine II Fast Ethernet Adapter - Packet Scheduler Miniport,100 Mbps [enter]

 

that way its an instant csv file so can be quickly thrown into excel

Posted
just thinking out loud here would it be better/possible to ditch the "InstanceName: " etc and the caridge returns and just output for example

 

pc1,VIA Rhine II Fast Ethernet Adapter,100 Mbps,VIA Rhine II Fast Ethernet Adapter - Packet Scheduler Miniport,100 Mbps [enter]

 

that way its an instant csv file so can be quickly thrown into excel

 

Well it's possible :p Not sure what Admiral prefers though, So either way can be done :p or you want it done to steal it?!?! lol

 

Steve

Posted (edited)
just thinking out loud here would it be better/possible to ditch the "InstanceName: " etc and the caridge returns and just output for example

 

pc1,VIA Rhine II Fast Ethernet Adapter,100 Mbps,VIA Rhine II Fast Ethernet Adapter - Packet Scheduler Miniport,100 Mbps [enter]

 

that way its an instant csv file so can be quickly thrown into excel

 

 

Just for you :p (Only a few lines change anyway)

 

Example:

ICTTECH-01,Intel® 82567LM-3 Gigabit Network Connection,1000 Mbps

 

Code:

'Define Variables for script

Dim NetName, NetSpeed, CompName, myFSO, WriteNetName

 

'Default Blank the variables

NetName = ""

NetSpeed = ""

CompName = ""

 

'Set File Links

Set myFSO = CreateObject("Scripting.FileSystemObject")

Set WriteNetName = myFSO.OpenTextFile("yourtextfile.txt", 8, True)

 

'Sets Computer Name/IP

strComputer = "."

 

'Links into Win32 system for information

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

 

'Scans data for Computer Name Information

For Each objItem in colItems

CompName = objItem.Name

Next

 

'Links into MSNDis_Linkspeed for information

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

 

Set colItems = objWMIService.ExecQuery("SELECT * FROM MSNdis_LinkSpeed",,48)

 

'Scans data for Net Speed and Name

For Each objItem in colItems

 

'Removes "slow/unused links"

if objItem.NdisLinkSpeed/10 > 1000 then

 

NetName = objItem.InstanceName

 

If objItem.NdisLinkSpeed/10 > 10000 Then

NetSpeed = objItem.NdisLinkSpeed/10000 & " Mbps"

Elseif objItem.NdisLinkSpeed/10 > 1000 then

NetSpeed = objItem.NdisLinkSpeed/10 & " kbps"

End If

 

'Writes data to file

WriteNetName.WriteLine(CompName & "," & NetName & "," & NetSpeed)

 

else

'Fall out clause for "non-used" connections

end if

 

Next

 

'closes Links and Resets items

WriteNetName.Close

SET WriteNetName = NOTHING

SET myFSO = NOTHING

 

 

 

 

*Edit - Files attached

 

NetworkSpeed.vbs

NetworkSpeedCSV.vbs

Edited by Steve21
Adding Files
  • Thanks 2
Posted

Steve, you are a vbs god!!!

 

one last thing...

 

can we get the results separated with a line i.e.

 

results 1

================

results 2

================

 

I owe you one!! virtual edubeer in the post!!

Posted
Steve, you are a vbs god!!!

 

one last thing...

 

can we get the results separated with a line i.e.

 

results 1

================

results 2

================

 

I owe you one!! virtual edubeer in the post!!

 

Which version? Original or CSV style as Sted said about?

 

And which bits seperate? :p Per computer? or like per line?

 

Post example please!

 

Steve

Posted

original per computer. ie.

 

====================================

Computer Name: ICTTECH-01

InstanceName: Intel® 82567LM-3 Gigabit Network Connection

NdisLinkSpeed: 1000 Mbps

====================================

Computer Name: ICTTECH-02

InstanceName: Intel® 82567LM-3 Gigabit Network Connection

NdisLinkSpeed: 1000 Mbps

====================================

Computer Name: ICTTECH-03

InstanceName: Intel® 82567LM-3 Gigabit Network Connection

NdisLinkSpeed: 1000 Mbps

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...