从适配器中按名称获取接口索引

Fetching Interfaceindex by name from adapter

我试图找出一种方法,通过在 PowerShell 脚本中按名称(如“WiFi”)进行搜索来动态获取适配器的接口索引号。 我想编写一个脚本,该脚本可以使用值配置这样的适配器,而无需人工读取表的信息。 有人见过类似的东西吗?

干杯

Get-NetAdapter 接受接口名称的通配符模式:

$wifiInterfaceIndices = Get-NetAdapter -Name *WiFi* |ForEach-Object InterfaceIndex