powershell中Get-NetAdapter获取网络适配器信息
Tags: OSpowershellWindows网络适配器
通用获取方法
追加 | fl 以列表格式化显示,| ft 以表格格式化显示(默认);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Get-NetAdapter | fl Name : Ethernet0 InterfaceDescription : Intel(R) 82574L Gigabit Network Connection InterfaceIndex : 11 MacAddress : 00-0C-29-D7-48-DD MediaType : 802.3 PhysicalMediaType : 802.3 InterfaceOperationalStatus : Up AdminStatus : Up LinkSpeed(Gbps) : 1 MediaConnectionState : Connected ConnectorPresent : True DriverInformation : Driver Date 2020-06-10 Version 12.18.9.23 NDIS 6.50 PS C:\Users\lhr> Get-NetAdapter | ft Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- Ethernet0 Intel(R) 82574L Gigabit Network Conn... 6 Up 00-0C-29-F1-B9-1E 1 Gbps Npcap Loopback Adapter Npcap Loopback Adapter 4 Up 02-00-4C-4F-4F-50 1.2 Gbps |
更多可选获取方法
Get-NetAdapter -Name *
获取所有可见的网络适配器。
Get-NetAdapter -Name * -IncludeHidden
获取所有网络适配器。
Get-NetAdapter -Name * -Physical
获取所有物理网络适配器
Get-NetAdapter -Name "Ethernet 2"
获取名为 Ethernet 2 的网络适配器。
Get-NetAdapter -Name "E*2"
使用通配符获取以 “E” 开头并以 “2” 结尾的适配器。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | PS C:\Users\lhr> Get-NetAdapter -Name * Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- Ethernet0 Intel(R) 82574L Gigabit Network Conn... 6 Up 00-0C-29-F1-B9-1E 1 Gbps Npcap Loopback Adapter Npcap Loopback Adapter 4 Up 02-00-4C-4F-4F-50 1.2 Gbps PS C:\Users\lhr> Get-NetAdapter -Name * -IncludeHidden Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- vSwitch (WSL) Hyper-V Virtual Switch Extension A...#2 23 Up 10 Gbps vEthernet (Default Swi... Hyper-V Virtual Ethernet Adapter 15 Up 00-15-5D-D1-6D-42 10 Gbps vEthernet (WSL) Hyper-V Virtual Ethernet Adapter #2 25 Up 00-15-5D-A7-9E-69 10 Gbps Teredo Tunneling Pseud... 16 Not Present 0 bps 以太网(内核调试器) Microsoft Kernel Debug Network Adapter 14 Not Present 0 bps vSwitch (Default Switch) Hyper-V Virtual Switch Extension Ada... 5 Up 10 Gbps Microsoft IP-HTTPS Pla... 7 Not Present 0 bps Ethernet0 Intel(R) 82574L Gigabit Network Conn... 6 Up 00-0C-29-F1-B9-1E 1 Gbps Npcap Loopback Adapter Npcap Loopback Adapter 4 Up 02-00-4C-4F-4F-50 1.2 Gbps 6to4 Adapter 2 Not Present 0 bps PS C:\Users\lhr> Get-NetAdapter -Name * -Physical Name InterfaceDescription ifIndex Status MacAddress LinkSpeed ---- -------------------- ------- ------ ---------- --------- Ethernet0 Intel(R) 82574L Gigabit Network Conn... 6 Up 00-0C-29-F1-B9-1E 1 Gbps Npcap Loopback Adapter Npcap Loopback Adapter 4 Up 02-00-4C-4F-4F-50 1.2 Gbps PS C:\Users\lhr> Get-NetAdapter -Name "Ethernet 2" Get-NetAdapter : 找不到任何“Name”属性等于“Ethernet 2”的 MSFT_NetAdapter 对象。请验证属性值,然后重试。 所在位置 行:1 字符: 1 + Get-NetAdapter -Name “Ethernet 2” + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Ethernet 2:String) [Get-NetAdapter], CimJobException + FullyQualifiedErrorId : CmdletizationQuery_NotFound_Name,Get-NetAdapter PS C:\Users\lhr> Get-NetAdapter -Name "E*2" PS C:\Users\lhr> |