有没有办法识别用于成功 ping 的网络适配器(或接口(interface))名称
我执行命令
ping google.com
成功了,我想知道使用的适配器是“Wi-Fi”Sunrise_5GHz_387918
c# 也有类似的问题 Identifying active network interface
但我正在寻找一种 Windows 批处理文件方式(可能是 powershell)。
最佳答案
您可以在 PS 中使用以下方法执行此操作:
get-wmiobject win32_networkadapter | select netconnectionid, name, InterfaceIndex, netconnectionstatus
或者,
您可以使用netsh
netsh interface ipv4 show interfaces
在 Windows 8 等较新版本的 PS 中,您甚至可以直接使用:
Get-NetAdapter | SELECT name, status, speed, fullduplex | where status -eq 'up'
请注意,netconnectionstatus 值指示连接状态。 2表示已连接
关于powershell - 如何在 Windows Bat 或 Powershell 中识别用于成功 ping 的网络适配器(或接口(interface))名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74717902/