#PSTip Detecting Wi-Fi adapters

Note: This tip requires PowerShell 3.0 or above.

Using WMI we can get a list of Wi-Fi adapters with the following command:

I could not find any documentation on the MSNdis_PhysicalMediumType class, but the values of the NdisPhysicalMediumType property maps onto OID_GEN_PHYSICAL_MEDIUM documented here. The integer values of the NdisPhysicalMediumType enum are missing but can be pulled out of the C/C++ header files in the SDK or WDK:

A value of 0 translates to NdisPhysicalMediumUnspecified, 1 to NdisPhysicalMediumWirelessLan, 14 translates to NdisPhysicalMedium802_3, and so on.

In Windows 8, this got a lot easier. With the NetAdapter module, we can quickly determine the physical media type of an adapter using the Get-NetAdapter cmdlet.

Notice that now we use the value of the media type, not the numeric value. The PhysicalMediaType definition shows the mapping:

Depending on your environment, you could also use this command to cover all Wi-Fi media types:

Lastly, here’s a valuable piece of information you might want to consider when you query Wireless adapters:

Native 802.11: Most WiFi drivers
Wireless LAN : Very old WiFi drivers
Wireless WAN : Some 3G/4G mobile broadband adapters (not all)

The latest Windows 8 telemetry shows that approximately 0.2% of WiFi adapters are of the “very old” variety.

About the author: Shay Levy

Shay Levy is a Co-founder and editor of the PowerShell Magazine. He is a multiple-year recipient of the Microsoft MVP award, and a Microsoft Certified Trainer (MCT). Shay often covers PowerShell related topics on his blog and you can also follow him on Twitter at @ShayLevy

Related Posts