You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用PowerShell识别处于‘identifying...’状态的Windows网络适配器

判断Windows网络适配器是否处于“Identifying...”状态的PowerShell方法

由于Get-NetAdapter没有直接返回网络识别状态的属性,你可以通过以下几种方法来检测适配器是否处于“Identifying...”状态:

方法1:结合Get-NetAdapter和Get-NetConnectionProfile

当网络处于识别中时,对应的网络连接配置要么未生成,要么NetworkCategory属性为Unidentified。可以通过关联适配器的接口索引来筛选:

# 获取所有处于识别状态的适配器
$identifyingAdapters = Get-NetAdapter | ForEach-Object {
    $profile = Get-NetConnectionProfile -InterfaceIndex $_.InterfaceIndex -ErrorAction SilentlyContinue
    # 两种情况:无对应连接配置,或配置为Unidentified
    if (-not $profile -or $profile.NetworkCategory -eq 'Unidentified') {
        $_
    }
}

# 输出结果
$identifyingAdapters | Select-Object Name, InterfaceIndex, Status

方法2:使用WMI查询Win32_NetworkConnectionProfile

WMI的Win32_NetworkConnectionProfile类直接包含网络分类信息,其中NetworkCategory值为0时代表未识别(即“Identifying...”状态):

# 获取未识别的网络配置,关联到对应的适配器
$unidentifiedProfiles = Get-WmiObject -Class Win32_NetworkConnectionProfile | Where-Object { $_.NetworkCategory -eq 0 }

$identifyingAdapters = $unidentifiedProfiles | ForEach-Object {
    Get-NetAdapter -InterfaceIndex $_.InterfaceIndex
}

# 输出结果
$identifyingAdapters | Select-Object Name, InterfaceIndex, Status

方法3:读取注册表检测

每个网络适配器的TCP/IP配置存储在注册表中,当处于识别状态时,NetworkCategory键通常不存在或值为0(需要管理员权限):

# 获取所有处于识别状态的适配器(需管理员权限)
$identifyingAdapters = Get-NetAdapter | ForEach-Object {
    $regPath = "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\$($_.InterfaceGuid)"
    $category = Get-ItemProperty -Path $regPath -Name NetworkCategory -ErrorAction SilentlyContinue | Select-Object -ExpandProperty NetworkCategory
    if (-not $category -or $category -eq 0) {
        $_
    }
}

# 输出结果
$identifyingAdapters | Select-Object Name, InterfaceIndex, Status

使用场景建议

  • 若无需管理员权限,优先使用方法1,它能覆盖大多数识别中的场景。
  • 方法2和方法3适用于更复杂的环境,比如需要精准匹配未识别状态的场景。

在你的自动化脚本中,可以先通过上述方法筛选出非识别状态的适配器,再执行Set-NetConnectionProfile等配置命令,避免出现报错。

内容的提问来源于stack exchange,提问作者Seven

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 08:57:33