批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[转载代码] [PowerShell每日技巧]查找无线网络适配器(20140317)

There are many ways of finding network adapters, but apparently none to identify active wireless adapters.

All information about your network adapters can be found right in the Registry, and here is a one-liner that provides all the information you may need:

PS C:\> Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Network\*\*\Connection' -ErrorAction SilentlyContinue | Select-Object -Property Name, DefaultNameIndex, MediaSubType
Local Area Connection* 69                                       69
Local Area Connection* 14                                       14
Wireless Network Connection                                    2 2


The interesting part is the MediaSubType value. Wireless adapters always are marked with a MediaSubType of 2.

So this line will always return wireless adapters only:

PS C:\> Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Network\*\*\Connection' -ErrorAction SilentlyContinue | Where-Object {$_.MediaSubType -eq 2} | Select-Object -Property Name, PnpInstanceID

Name                                              PnpInstanceID
----                                              -------------
Wireless Network Connection                       PCI\VEN_14E4&DEV_4353&SUBSYS_00E9106...


http://powershell.com/cs/blogs/tips/archive/2014/03/17/finding-wireless-network-adapters.aspx

返回列表