Use PowerShell 3.0 to Work with Network Adapters

Summary: Learn how to use the Get-NetAdapter CIM cmdlet in Windows PowerShell 3.0.

Microsoft Scripting Guy, Ed Wilson, is here. I must live a rather boring life—although to be honest, it does not really seem to be so boring. Or perhaps, I am just a geek. What am I talking about? I am really excited about the Get-NetAdapter cmdlet in Windows 8 and Windows Server 2012 with Windows PowerShell 3.0. It allows me to easily determine the status of my network adapter. Perhaps because I spend so much time traveling around with my laptop, I am constantly connecting to various networks—wired or wireless.

Personally, I do not like the idea of bridged network connections, and therefore, I always disable the network adapter that I am not currently using. At times, however, I do forget to re-enable that network adapter, and I always spend a few mips before I remember to toggle my network adapters. I wrote a Hey, Scripting Guy! Blog about this a few years ago, How Can I Enable or Disable My Network Adapter. Although it was a cool script, it was a lot of work. With Windows 8 and Windows Server 2012 with Windows PowerShell 3.0, all that has changed—working with network adapters is a piece of cake.

Find and identify your network adapters

The Get-NetAdapter cmdlet returns the name, interface description, index number, and status of all network adapters that are present on the system. This is the default display of information, and it is shown in the image that follows.

Image of command output

To focus on a particular network adapter, I use the name parameter and supply the name of the network adapter. The good thing is that in Windows 8 and Windows Server 2012 the network connections receive new names. No more of the “local area connection” and “local area connection(2)” to attempt to demystify. The wired network adapter is simply Ethernet and the wireless network adapter is Wi-Fi. The following command retrieves only then Ethernet network adapter.

Get-NetAdapter -Name Ethernet

To dive into the details of the Ethernet network adapter, I pipe the returned object to the Format-List cmdlet, and I choose all of the properties. The command shown here uses the fl alias for the Format-List cmdlet.

Get-NetAdapter -Name ethernet | fl *

The command and the output associated with the command are shown in the following image.

Image of command output

There are a number of excellent properties that might bear further investigation. For example, there are the AdminStatus and the MediaConnectionStatus properties. The following command returns these properties.

Get-NetAdapter -Name ethernet | select adminstatus, MediaConnectionState

Of course, there are other properties that might be interesting also. These properties are shown here, along with the associated output (the following is a single logical command broken on two lines).

Get-NetAdapter -Name ethernet |

select ifname, adminstatus, MediaConnectionState, LinkSpeed, PhysicalMediaType


ifName               : Ethernet_7

AdminStatus          : Down

MediaConnectionState : Unknown

LinkSpeed            : 0 bps

PhysicalMediaType    : 802.3

I decide to look only for network adapters that are in the admin status of up. I use the command shown here.

PS C:\> Get-NetAdapter | where adminstatus -eq "up"


Name                      InterfaceDescription                    ifIndex Status

----                      --------------------                    ------- ------

vEthernet (InternalSwi... Hyper-V Virtual Ethernet Adapter #3          22 Up

vEthernet (ExternalSwi... Hyper-V Virtual Ethernet Adapter #2          19 Up

Bluetooth Network Conn... Bluetooth Device (Personal Area Netw...      15 Disconn...

Wi-Fi                     Intel(R) Centrino(R) Ultimate-N 6300...      12 Up

To find the disabled network adapters, I change the AdminStatus from up to down as shown here.

Get-NetAdapter | where adminstatus -eq "down"

I go back to my previous command, and modify it to return Wi-Fi information. This command and associated output are shown here (this is a single logical command).

PS C:\> Get-NetAdapter -Name wi-fi |

select ifname, adminstatus, MediaConnectionState, LinkSpeed, PhysicalMediaType


ifName               : WiFi_0

AdminStatus          : Up

MediaConnectionState : Connected

LinkSpeed            : 54 Mbps

PhysicalMediaType    : Native 802.11

If I want to find any network adapters that are sniffing the network, I look for PromiscousMode. This command is shown here.

Get-NetAdapter | ? PromiscuousMode -eq $true

Join me tomorrow when I will present additional information about using Windows PowerShell 3.0 to work with network adapters.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Comments (7)

  1. Nfields03 says:

    I believe most of this functionality relied more on Win8/Server2012 than on PS3.0, but it would be nice if they backported it to a Win7/2008R2 SP2…

  2. I didn't think you can do that much wich PS!

  3. Klaus Schulte says:

    Hi Ed,

    it's good to see that PS V3 offers a lot more useful cmldlets that V2 had!

    But … as I don't seem to have this cmdlet on my Wn7 Windows Management Framework 3.0 RC here …

    is it planned to "synchronize" the final version of PS3 for Win7 and Win8 ?

    Or will Win7 be left behind and only Win8 will have all these nice new cmdlets?

    In this case most of us will only be able to follow your introduction into the new V3 features theoretically 🙁


  4. Nob says:

    @Klaus Shulte : unless i'm mistaken, only Windows 8 and Windows Server 2012 support those cmdlets.

  5. Pete S says:

    I’m on Windows 8.1 Pro, when I try to do this, I get this.

    PS C:Windowssystem32> Get-NetAdapter
    Get-NetAdapter : Invalid class
    At line:1 char:1
    + Get-NetAdapter
    + ~~~~~~~~~~~~~~
    + CategoryInfo : MetadataError: (MSFT_NetAdapter:ROOT/StandardCimv2/MSFT_NetAdapter) [Get-NetAdapter], CimException
    + FullyQualifiedErrorId : HRESULT 0x80041010,Get-NetAdapter

    When I look at the list of modules, NetAdapter is in there as an available module.

  6. Ramesh says:

    Hi ,

    I use Powershell 4.0 where I am not able to run the command Get-NetAdapter.

    Error Message :
    get-netadapter : The term ‘get-netadapter’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the

    name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:1
    + get-netadapter
    + ~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (get-netadapter:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

  7. JPFe says:

    Hi, I just started using PS. On most installations, get-netadapter works, and now now that I´m using Win7 64Bit Pro, all that I get is:
    PS U:> get-netadapter
    get-netadapter : Die Benennung "get-netadapter" wurde nicht als Name eines Cmdlet, einer

    Funktion, einer Skriptdatei oder eines ausführbaren Programms erkannt. Überprüfen Sie die

    Schreibweise des Namens, oder ob der Pfad korrekt ist (sofern enthalten), und wiederholen Sie

    den Vorgang.
    In Zeile:1 Zeichen:1
    + get-netadapter
    + ~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (get-netadapter:String) [], CommandNotFoundExce
    + FullyQualifiedErrorId : CommandNotFoundException

    PS U:> $psversiontable

    Name Value
    —- —–
    PSVersion 3.0
    WSManStackVersion 3.0
    CLRVersion 4.0.30319.34209
    BuildVersion 6.2.9200.16481
    PSCompatibleVersions {1.0, 2.0, 3.0}
    PSRemotingProtocolVersion 2.2

    MS .net Framework 4.5.2 is installed, Windows Updates are up to date.
    Which Modules are needed to get the functionality?

Skip to main content