40

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.

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.

| improve this answer | |
  • 1
    and 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 Nov 24 '14 at 2:04
  • 2
    That 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 Nov 25 '14 at 19:39
  • Just what I needed! You are a great person ;n; +1 (P.S. is that bits-per-second?) – Cardinal - Reinstate Monica Apr 26 '19 at 20:43
  • 1
    @CardinalSystem Yes, it's bits per second. – Indrek Apr 27 '19 at 21:35
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

| improve this answer | |
  • That's strange. It works without the quotes here. – DavidPostill Jun 4 '16 at 10:40
  • @DavidPostill It breaks the GET expression in PS (once you add a second item). – Louis Waweru Oct 20 '16 at 5:32
  • 1
    Ah. Confirmed. You should add to your answer that the quotes are required for PowerShell and not needed in a cmd shell. – DavidPostill Oct 20 '16 at 7:18
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/
| improve this answer | |
  • \b doesn't work with sed in Cygwin. What works for me is [^0]. Or, to be complete: s/000000[^0]/Mbit/ – pepoluan Apr 11 '16 at 2:30
  • Except that will swallow the first non-zero character after 000000, which might not be what you want. – Wodin Apr 28 '16 at 8:13
-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

| improve this answer | |
  • so why is the answer downvoted.? – Green Tree Feb 13 '19 at 12:02
  • 1
    I don't know, it seems still zero here :S. Ow mabye because this is Linux only.. – Melroy Mar 1 '19 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.