- 帖子
- 2874
- 积分
- 7021
- 技术
- 336
- 捐助
- 0
- 注册时间
- 2011-6-2
|
[转载代码] [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 |
|