Getting information about network adapters with PowerShell

In PowerShell v3 we’ve got a new cmdlet: Get-NetAdapter.
So, what can we do with this?

First, what output does this cmdlet give us?

Command: Get-NetAdapter
1

So could you use the help feature in PowerShell to get a view of the possible parameters and syntax this cmdlet offers?

Command: Get-Help Get-NetAdapter
2

As you can see, there is a –IncludeHidden parameter which include any hidden network adapters in your output:

Command: Get-NetAdapter –IncludeHidden
3

But there also is a –Physical parameter which will only include physical network adapters in your output?

Command: Get-NetAdapter –Physical
4

So what if you want to get the virtual network adapters instead of the physical?
Well, there isn’t a cmdlet included for that, so you can simply filter on the property value, right?

Command: Get-NetAdapter | Where {$_.Virtual –eq $True}
5

You can also easily filter on the description by using the –InterfaceDescription parameters.
For example… let’s get all the network adapters with “Hyper-V” in the description?

Command: Get-NetAdapter –InterfaceDescription “*Hyper-V*”
6

Here is how you get some basic information about the driver which is used by the adapter

Command: Get-NetAdapter | select name, drivername, majordriverversion, minordriverversion, driverinformation
7

And to get information about the linkspeed and such?

Command: Get-NetAdapter | select vlandid, promiscuousmode, portnumber, networkaddress, permanentaddress, mediatype
8

And the last one in the category of information gathering, to get some information about the state and capabilities of the network adapter?

Command: Get-NetAdapter | select transmitlinkspeed, physicalmediatype, mediaconnectionstate, speed, requestedspeed, maxspeed, fullduplex, linkspeed

9

 

 

2 comments

  1. Dshcook says:

    How can I use this to get driver information on 500 computers. Would it just be a import-csv syntax and then this cmdlet?

  2. Jeff Wouters says:

    Not exactly since the Get-NetAdapter cmdlet doesn’t have a ComputerName parameter.
    However, it does have a CimSession parameter so you could do something like:

    $Computers = Import-CSV -Path D:\MyComputers.csv | Select-Object -ExpandProperty ComputerName
    $CimSession = New-CimSession -ComputerName $Computers
    Get-NetAdapter -CimSession $CimSession

Leave a Reply

Your email address will not be published. Required fields are marked *