gpt4 book ai didi

windows - 通过命令提示符只获取以太网 MAC 地址

转载 作者:行者123 更新时间:2023-12-03 11:08:01 27 4
gpt4 key购买 nike

我使用 'ipconfig/all' 或 'getmac/v' 来获取所有 NIC 物理地址。

但问题是,一般一台电脑有多个网卡。此外,还有一些虚拟 MAC 地址,例如 Microsoft 虚拟 wifi 热点网卡,仅在 wifi 热点打开时显示。

那么,如何通过cmd只收集以太网对应的地址呢?

最佳答案

我建议你使用powershell,因为它比cmd强大

Get-CimInstance win32_networkadapterconfiguration | select description, macaddress | where {$_.MACAddress -ne $n
ull }

输出 :
description                                                 macaddress
----------- ----------
RAS Async Adapter 20:41:53:59:4E:FF
Realtek PCIe GBE Family Controller 18:03:73:65:64:AB
VMware Virtual Ethernet Adapter for VMnet1 00:50:56:C0:00:01
VMware Virtual Ethernet Adapter for VMnet8 00:50:56:C0:00:08

powershell 中的该命令选择设备的所有 macaddress 启用包含 vmware 的机器,但我们可以做更多的过滤,例如
Get-CimInstance win32_networkadapterconfiguration | select description, macaddress | where {$_.MACAddress -ne $n
ull } | where {$_.Description -match "Realtek" }

输出 :
description                                                 macaddress
----------- ----------
Realtek PCIe GBE Family Controller 18:03:73:65:64:AB

但是如果你只是在 cmd 中运行,你应该像这样在 powershell 中编码这个命令
$script={ Get-CimInstance win32_networkadapterconfiguration | select description, macaddress | where {$_.MACAddr
ess -ne $null } | where {$_.Description -match "Realtek" } }

[System.Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes( $script))

输出 用于 cmd 的编码命令
IABHAGUAdAAtAEMAaQBtAEkAbgBzAHQAYQBuAGMAZQAgAHcAaQBuADMAMgBfAG4AZQB0AHcAbwByAGsAYQBkAGEAcAB0AGUAcgBjAG8AbgBmAGkAZwB1AHI
AYQB0AGkAbwBuACAAfAAgAHMAZQBsAGUAYwB0ACAAZABlAHMAYwByAGkAcAB0AGkAbwBuACwAIABtAGEAYwBhAGQAZAByAGUAcwBzACAAfAAgAHcAaABlAH
IAZQAgAHsAJABfAC4ATQBBAEMAQQBkAGQAcgBlAHMAcwAgAC0AbgBlACAAJABuAHUAbABsACAAfQAgACAAfAAgAHcAaABlAHIAZQAgAHsAJABfAC4ARABlA
HMAYwByAGkAcAB0AGkAbwBuACAALQBtAGEAdABjAGgAIAAiAFIAZQBhAGwAdABlAGsAIgAgAH0AIAA=

在 cmd 中,我使用它并获得 mac
powershell -encodedcommand IABHAGUAdAAtAEMAaQBtAEkAbgBzAHQAYQBuA
GMAZQAgAHcAaQBuADMAMgBfAG4AZQB0AHcAbwByAGsAYQBkAGEAcAB0AGUAcgBjAG8AbgBmAGkAZwB1A
HIAYQB0AGkAbwBuACAAfAAgAHMAZQBsAGUAYwB0ACAAZABlAHMAYwByAGkAcAB0AGkAbwBuACwAIABtA
GEAYwBhAGQAZAByAGUAcwBzACAAfAAgAHcAaABlAHIAZQAgAHsAJABfAC4ATQBBAEMAQQBkAGQAcgBlA
HMAcwAgAC0AbgBlACAAJABuAHUAbABsACAAfQAgACAAfAAgAHcAaABlAHIAZQAgAHsAJABfAC4ARABlA
HMAYwByAGkAcAB0AGkAbwBuACAALQBtAGEAdABjAGgAIAAiAFIAZQBhAGwAdABlAGsAIgAgAH0AIAA=

输出:
description                             macaddress
----------- ----------
Realtek PCIe GBE Family Controller 18:03:73:65:64:AB

关于windows - 通过命令提示符只获取以太网 MAC 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29201132/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com