How to detect the speed (fast or gigabit ethernet) of a network connection over Windows command line

40

13

To troubleshoot a network problem I would like to inquire the real network "speed" for a given network adapter, which can be seen when opening the "status" of a network connection under Windows: Speed setting

However I want to inquire this over the command line or with a small, separate tool because I need to request this for multiple network connections and don't trust the user to fetch the information properly. The network card "Speed/Duplux" setting is always "Auto Negotiate", so I can't tell from that what "Speed" I will get.

asdrubael

Posted 2012-04-16T07:57:40.093

Reputation: 607

Answers

63

Try this WMI query:

wmic NIC where NetEnabled=true get Name, Speed

That should give you the speed of all active network connections.

Edit: as has been pointed out, this query has to be modified to work in PowerShell (it works fine in cmd.exe though). Then again, in PowerShell you don't need to use WMI at all:

Get-NetAdapter | where Status -eq "Up" | select InterfaceDescription, LinkSpeed

As a bonus, this gives the speed in a nice, human-readable format (e.g. "1 Gbps"), rather than the number of bits per second.

Indrek

Posted 2012-04-16T07:57:40.093

Reputation: 21 756

1and if you have sed wmic NIC where NetEnabled=true get Name, Speed | sed -e s/000000000/Gbit/ | sed -e s/000000\b/Mbit/ – Jamie Cook – 2014-11-24T02:04:42.063

2That WMI query worked in Windows 8 cmd, but in Windows 7, I had to use this: wmic NIC where "NetEnabled='true'" get "Name,Speed" It seems that the cmd shell was trying to interpret the ',' as a space or command separator. PowerShell has this problem, also. Thanks for putting me on the right path! – The Dude – 2014-11-25T19:39:14.923

Just what I needed! You are a great person ;n; +1 (P.S. is that bits-per-second?) – Cardinal - Reinstate Monica – 2019-04-26T20:43:33.877

1@CardinalSystem Yes, it's bits per second. – Indrek – 2019-04-27T21:35:32.303

6

From Indrek's answer:

wmic NIC where NetEnabled=true get Name, Speed

will work in the Command Prompt. For PowerShell use:

wmic NIC where "NetEnabled='true'" get "Name,Speed"

(The where clause, and any get attribute (like Name and Speed), must be enclosed in double quotes and comma-delimited).

// Edit #1: GET expression Name,Speed has to be enclosed within a single set of double quotes. Get expressions may not have a space between them

Tom

Posted 2012-04-16T07:57:40.093

Reputation: 161

That's strange. It works without the quotes here. – DavidPostill – 2016-06-04T10:40:39.983

@DavidPostill It breaks the GET expression in PS (once you add a second item). – Louis – 2016-10-20T05:32:37.333

1Ah. Confirmed. You should add to your answer that the quotes are required for PowerShell and not needed in a cmd shell. – DavidPostill – 2016-10-20T07:18:50.743

2

I would like to contribute to your share. If you need to run sed in Windows, you can download UnxUtils, then extract sed.exe into c:\Windows\System32

Then when you pipe with sed like you suggested, it works. (Windows 8.1)

Thanks.

wmic NIC where NetEnabled=true get Name, Speed | sed -e s/000000000/Gbit/ | sed -e s/000000\b/Mbit/

sdkks

Posted 2012-04-16T07:57:40.093

Reputation: 189

\b doesn't work with sed in Cygwin. What works for me is [^0]. Or, to be complete: s/000000[^0]/Mbit/ – pepoluan – 2016-04-11T02:30:03.337

Except that will swallow the first non-zero character after 000000, which might not be what you want. – Wodin – 2016-04-28T08:13:01.220

-1

You can also use:

cat /sys/class/net/enp6s0/speed

Or when it's eth0, to determine your speed connection (100 or 1000):

cat /sys/class/net/eth0/speed

Melroy

Posted 2012-04-16T07:57:40.093

Reputation: 137

so why is the answer downvoted.? – Green Tree – 2019-02-13T12:02:17.990

1I don't know, it seems still zero here :S. Ow mabye because this is Linux only.. – Melroy – 2019-03-01T18:00:22.857