Admiral208 Posted March 10, 2011 Posted March 10, 2011 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
mac_shinobi Posted March 10, 2011 Posted March 10, 2011 (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 March 10, 2011 by mac_shinobi 1
Michael Posted March 10, 2011 Posted March 10, 2011 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. 2
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 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.
SYNACK Posted March 16, 2011 Posted March 16, 2011 This will grab the ibformation your after: VBScript - List Speed & Duplex settings on network adapters using WMI and this shows writing to a text file: Writing to a text file using vbscript - IT Management Forum 1
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 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??
Steve21 Posted March 16, 2011 Posted March 16, 2011 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 Steve 1
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 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.
Steve21 Posted March 16, 2011 Posted March 16, 2011 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 1
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 the first post worked perfectly. trying this one, i get an error message line: 27 char: 21 error: expected end of statement code: 800A0401
Steve21 Posted March 16, 2011 Posted March 16, 2011 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 But try that one. Think I named "Name" wrong in first one.
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 error line 18: object doesnt support this property or method: 'objitem.computer name
Steve21 Posted March 16, 2011 Posted March 16, 2011 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
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 Sorry. thats me not being able to copy text correctly. there is no space between computer and name
Steve21 Posted March 16, 2011 Posted March 16, 2011 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 Try that and gimme a shout, Steve 1
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 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.
Steve21 Posted March 16, 2011 Posted March 16, 2011 I believe this should do it, tried to comment code a bit too 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!
Steve21 Posted March 16, 2011 Posted March 16, 2011 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
sted Posted March 16, 2011 Posted March 16, 2011 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
Steve21 Posted March 16, 2011 Posted March 16, 2011 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 Not sure what Admiral prefers though, So either way can be done or you want it done to steal it?!?! lol Steve
Steve21 Posted March 16, 2011 Posted March 16, 2011 (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 (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 March 16, 2011 by Steve21 Adding Files 2
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 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!!
Steve21 Posted March 16, 2011 Posted March 16, 2011 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? Per computer? or like per line? Post example please! Steve
Admiral208 Posted March 16, 2011 Author Posted March 16, 2011 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now