检测以太网适配器 - PowerShell

3

我正在使用这段代码来检测网络适配器:

(Get-NetAdapter).InterfaceDescription

这段代码的问题在于它检测到所有的网络适配器(包括VMware虚拟适配器和Wi-Fi适配器)。

我只想检测设备上安装的以太网适配器。

PowerShell能做到吗?


1
Get-NetAdapter | where-object interfacedescription -like "以太网" - another victim of the mouse
1
个人而言,我会使用 Get-NetAdapter | where physicalmediatype -eq 802.3 - AdminOfThings
3
该命令有一个“-Physical”开关参数。这将除去虚拟的部分...然后你可以按照AdminOfThings提到的方式过滤物理介质类型。 - Lee_Dailey
2个回答

3
(Get-NetAdapter -Physical | Where-Object {$_.PhysicalMediaType -eq "802.3"}).InterfaceDescription

将获取所有物理网络适配器,其物理媒体类型为802.3(以太网)。


1

Get-NetAdapter | Where-Object {$_.InterfaceDescription -match "以太网"}

这将显示内置以太网适配器以及扩展坞/USB以太网适配器。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接