I am trying to get the NIC speed via Powershell on some of my servers. For my lab server I know there is a 1GB NIC in there. However, when I do this via Powershell I get the below weird number:
Get-WmiObject -Class Win32_NetworkAdapter -filter "Name LIKE '%Intel%' OR Name LIKE '%HP%' OR Name LIKE '%Broadcom%'" | select name, speed | ft -AutoSize
name speed
---- -----
Intel(R) 82580 Gigabit Network Connection 9223372036854775807
The speed I am getting back is "9223372036854775807
" - I checked the WMI property for Speed in Win32_NetworkAdapter
and it returns "Bits per second
" - however, in conversion this looks like a lot more than 1GB per second?
Any idea on why I am getting this back and also the best way of determining NIC speed (and to confirm that it definitely is 1GB)?
As I have many servers - I really would prefer to know the best way of getting this info if you have any ideas.
Get a list of Domain Computers (Run in AD):
Import-Module ActiveDirectory Get-ADComputer -Filter * | ForEach-Object {$_.Name}
Or from a file:
For multiple computers:
That will print for each computer in list:
Note: Speed is in bits per second, convert to Gbps or Mbps as necessary
For the original query, if you replace
speed
with@{n="Speed";e={$_.speed/1mb}}
, it return a calculated result, in Mega-bits.If you do
@{n="Speed";e={$_.speed/1gb}}
, it will return result in Gbits respectfully.Powershell does not aware what the original measure is, and MB/mb is the same to powershell. Thus if you need the result to be in bytes, you have manually divide by the result by another 8,
@{n="Speed";e={$_.speed/1mb/8}}
The altered script would be:
And this alternative format
@{n="name";e={$_.property *operations*}}
would work for any select in powershell.