Use PowerShell to Identify Your Real Network Adapter

Summary: Learn how to use Windows PowerShell to identify easily the real network adapter.


Hey, Scripting Guy! QuestionHey, Scripting Guy! I have a problem that perhaps you can assist with. I know about WMI, and I know there is a class that represents a network adapter. The problem is that when I run the command, I get back lots of stuff that is not a real network adapter. I am sure I am not the first person to see this problem, so I want to know how other people solve this problem.



Hey, Scripting Guy! AnswerHello BP,

Microsoft Scripting Guy Ed Wilson here. This is one of the problems with technology—it is always changing. In the old days, it was relatively simple to use WMI to work with network adapters. All one needed to do was to choose the adapter that had the ipenabled property set to true. An example of a script that uses this technique is in the How Can I Change the IP Address Assigned to a Computer? blog post.

On my laptop today, that approach still works. The command to find a network adapter that is IP enabled is shown here along with the associated output:

PS C:\> Get-WmiObject win32_networkadapterconfiguration -Filter ‘ipenabled = “true”‘


DHCPEnabled      : True

IPAddress        : {, fe80::fd99:3ef6:799f:dc0b}

DefaultIPGateway : {}

DNSDomain        :

ServiceName      : netw5v64

Description      : Intel(R) Wireless WiFi Link 4965AGN

Index            : 13

Cool. However, there is a problem. This command retrieves the configuration of the network adapter; it does not get the network adapter itself. For example, if I want to change the IP address or the DNS server address, I use the Win32_networkadapterconfiguration class. If I want to enable or disable a network card, I use the win32_networkadapter class. The bad thing is that the Win32_Networkadapter class does not have an ipenabled property. When I attempt to use such a command, an error is displayed such as the one shown here:

PS C:\> Get-WmiObject win32_networkadapter -Filter ‘ipenabled = “true”‘


Get-WmiObject : Invalid query

At line:1 char:14

+ Get-WmiObject <<<<  win32_networkadapter -Filter ‘ipenabled = “true”‘

    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException

    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObject Command

The good thing is that both the Win32_networkadapterconfiguration class and the win32_NetworkAdapter WMI class both share the index property. This means I can use the result of one query to feed into a query for the other class. In the following example, I find the network adapter that is ipenabled, get the index number of that adapter, and return the network adapter itself:

PS C:\> $a = Get-WmiObject win32_networkadapterconfiguration -Filter ‘ipenabled = “true”‘

PS C:\> $a.Index


PS C:\> Get-WmiObject win32_networkadapter -Filter ‘index = 13’

ServiceName      : netw5v64

MACAddress       : 00:1F:3B:AD:FF:6D

AdapterType      : Ethernet 802.3

DeviceID         : 13

Name             : Intel(R) Wireless WiFi Link 4965AGN

NetworkAddresses :

Speed            : 36000000

Another way to find a specific network adapter is to look at the maker of the adapter or the description of the adapter. For example, on my laptop the same company makes both the wired Ethernet connection and the wireless network adapter. You cannot rely upon using only the network adapter that is connected, because more than one network adapter could be connected at the same time. Fortunately, both win32_networkadapter and win32_networkadapterconfiguration WMI classes contain a description property. On my laptop, the two outputs are identical:

PS C:\> Get-WmiObject win32_networkadapterconfiguration -Filter ‘index = 13’ | select description



Intel(R) Wireless WiFi Link 4965AGN


PS C:\> gwmi win32_networkadapter -filter ‘index = 13’ | select description



Intel(R) Wireless WiFi Link 4965AGN


One of the tricks I use so that I can always find the correct network adapter is assign specific names to the network adapters. Using WMI and the Win32_networkadapter class, I can create a new name for the netconnectionID property. This technique is shown here. Note   This command requires administrator rights.

$adapter = Gwmi win32_networkadapter -Filter ‘index = 13’

$adapter.NetConnectionID = “ScriptingGuys”


The commands and their associated output are shown in the following figure.

Image of commands and associated output

The following figure shows that the command was successful.

Image showing command was successful

After I have an easy-to-use network adapter name, I can use it in queries directly:

PS C:\> gwmi win32_networkadapter -Filter ‘netconnectionid = “scriptingguys”‘


ServiceName      : netw5v64

MACAddress       : 00:1F:3B:AD:FF:6D

AdapterType      : Ethernet 802.3

DeviceID         : 13

Name             : Intel(R) Wireless WiFi Link 4965AGN

NetworkAddresses :

Speed            : 48000000

I have always made it a practice to name my network adapters. In the past, it required a pretty extensive VBScript to accomplish, or it required manual intervention (or it required using netsh). Now, a very short Windows PowerShell command accomplishes the task.

Well, BP, that is all there is to working with the network adapter, index names, and NetConnectionIDs. I invite you to join me tomorrow for more Windows PowerShell cool tricks.


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 (16)

  1. Anonymous says:

    How would you execute these commands for a remote machine on the network? I want to do this, but I want to display all machines on our domain with a certain network card installed. All our users are on AD.

    Sorry, I’m new at this.


  2. Chris J Warwick says:

    You should connect the Win32_NetworkAdapterConfiguration to the associated Win32_NetworkAdaptor like this:

    $NetAdapterConfig=gwmi win32_networkadapterconfiguration -filter 'ipenabled="true"'

    # (there may be more than one of these, so you might need to select one of them…  then…)

    # Get the associated NetAdpater



    Chris Warwick


  3. jrv says:

    @ken  Read the definitions in the link. NetEnabled is not anything like IPenabled.

    IPenabled telss us the it is a configured TCP-IP adapter.  NetEnabled only tells us that the adapter (any kind of adapter) is enabled.

    This logic you use is meaningless.  Think about it.

    {$_.netenabled -eq "true" -OR $_.netenabled -eq "false"}

    There are only two possibilities.  Including both is identical to including none.

  4. jrv says:


    yOu have your true and false all bollixed up.

    Try thgis to see what I mean.

    Get-WmiObject -Class Win32_NetworkAdapter  | where {$_.netenabled -ne $false}

    Notice that in PowerShell we use $true and $false. These are booleans and NOT strings.

  5. JV says:


    You can hjsut PosH it:

    gwmi win32_networkadapterconfiguration -filter 'ipenabled="true"'


    Get them all with no errors.

  6. ed wilson says:

    @jv that is a cool technique.

  7. JV says:


    To be more clear. I just started to learn those underlying bits about WMI.  I have been probing under the covers lately.  I can't remember which blog triggered my interest in that. If I remember I will post the link here,

    The WMF team seems to be working on new things for WMI.  I suspect the surprises will be even better than those little ditties they put into PosH V2 WMI (WMF 2.0).

    If WMI can reach the operational and logical consistency of PowerShell we will have a wonderful tool. Currently WMI is a bit ambiguous and somewhat difficult to understand.  The future looks to be much brighter.

    Those two decorations (Related/Relationships) are muxh moreintuitive that CIM semantics.

    Happy tinkering….

  8. Ed Wilson says:

    @JV WMI is fun to play with … but it really is inconsistent. For some things, it is the ONLY way to manage them. You are correct, PowerShell 2.0 brought some nice new features.

  9. JV says:


    I don't find WMI all that inconsistent until you get into Vendor additions like HP and Dell.  Then it gets real screwy,  MOst of the bas CIM and Win32/MSFT classes are fairly easy to understand.  It is an older management model but the WMF Team looks to be serious about rethinking its use and usability.

    Maybe 3.0 will bring some relief.

  10. Ed Wilson says:

    @JV I agree with the basics, win32_bios, win32_logicaldick, win32_processor etc. are all pretty standard. It is when you move from the WBEMCORE classes that things get exciting 🙂

  11. Daniel Smith says:

    Great article and lots of wisdom here.

  12. Ken Aldrich says:

    Based on your post, I spent a lot of time figuring this out:

    $ids = Get-WmiObject -Class Win32_NetworkAdapter -computer SOME_REMOTE_COMPUTER | where-object {$_.netenabled -eq "true" -OR $_.netenabled -eq "false"} | select -expandproperty index

    ForEach ($id in $ids)


    Get-WmiObject -Class Win32_NetworkAdapterConfiguration -computer SOME_REMOTE_COMPUTER -filter "index = $id" | ft Description,IPAddress,IPEnabled,Index,MACAddress -autosize


    Then I took a closer look at the Win32_NetworkAdapter class here:…/aa394216%28VS.85%29.aspx

    I discovered that you can do it, your script is just using the wrong name.  Use "netenabled" intead of "ipenabled".

    This is much simpler than the above.

    Get-WmiObject -Class Win32_NetworkAdapter -computer SOME_REMOTE_COMPUTER | where-object {$_.netenabled -eq "true" -OR $_.netenabled -eq "false"} | ft Description,NetEnabled,Index,MACAddress -autosize

  13. Ken A. says:

    I wish I could take some of that back.  This part doesn't work right:

    Where {$_.IpEnabled -eq 'False'}

    It still only returns interfaces where IpEnabled is 'True'.  Oh well.  So, it looks like the first version still works best.

    Happy scripting.

  14. Ken A. says:

    Get-WmiObject -Class Win32_NetworkAdapter  | where {$_.netenabled -eq 'False'} | ft index,netenabled

                                                                           index                                                                    netenabled

                                                                           —–                                                                    ———-

                                                                              10                                                                          True

                                                                              19                                                                          True

  15. arun says:

    How to get the Device ID, using only the Name : Intel(R) Wireless WiFi Link 4965AGN?????????????

  16. Scott says:

    this was a HUGE help.
    i needed to use ipenabled and ipaddress so i had to use win32_networkadapterconfiguration but my end goal was to restart the NIC so i had to pull it back into win32_networkadapter format. i started to realize this before reading this blog but this helped me
    finish the deal.
    thanks! scott

    ps. i like the ‘shortcut’ but while $NIC.GetRelated(‘win32_networkadapter’) works, $NIC = $NIC.GetRelated(‘win32_networkadapter’) doesn’t give me the same result.