有没有办法使用 powershell (Win10) 识别设备的 PCIE 速度?

Aus*_*ang 2 motherboard pci-express powershell windows-10

这样我就可以确定设备的传输速率并将其与 PCIE 设备的生成(PCIE 3.0、4.0 等)相关联

Cpt*_*ale 7

此方法使用 WMI 总线 PnP 设备驱动程序属性

# Get all devices related to PCI BUS 
$pciStats = (Get-WMIObject Win32_Bus -Filter 'DeviceID like "PCI%"').GetRelated('Win32_PnPEntity') | 
  foreach {
    # request connection properties from wmi
    [pscustomobject][ordered]@{
      Name = $_.Name
      ExpressSpecVersion=$_.GetDeviceProperties('DEVPKEY_PciDevice_ExpressSpecVersion').deviceProperties.data
      MaxLinkSpeed      =$_.GetDeviceProperties('DEVPKEY_PciDevice_MaxLinkSpeed'      ).deviceProperties.data
      MaxLinkWidth      =$_.GetDeviceProperties('DEVPKEY_PciDevice_MaxLinkWidth'      ).deviceProperties.data
      CurrentLinkSpeed  =$_.GetDeviceProperties('DEVPKEY_PciDevice_CurrentLinkSpeed'  ).deviceProperties.data
      CurrentLinkWidth  =$_.GetDeviceProperties('DEVPKEY_PciDevice_CurrentLinkWidth'  ).deviceProperties.data
    } |
    # only keep devices with PCI connections
    Where MaxLinkSpeed
  }
$pciStats | Format-Table -AutoSize
Run Code Online (Sandbox Code Playgroud)

它在我的电脑上显示了这样的表格:

Name                             ExpressSpecVersion MaxLinkSpeed MaxLinkWidth CurrentLinkSpeed CurrentLinkWidth
----                             ------------------ ------------ ------------ ---------------- ----------------
High Definition Audio Controller                  2            4           16                3               16
NVIDIA GeForce RTX 3070                           2            4           16                3               16
Intel(R) Dual Band Wireless-AC 8                  2            1            1                1                1
ASMedia USB 3.1 eXtensible Host                   2            3            2                3                2
Standard NVM Express Controller                   2            3            4                3                4
Run Code Online (Sandbox Code Playgroud)

该ExpressSpecVersion属性是 PCIe 版本,其中 PCIe 1.0 =0和 PCIe 3.0 =2等。其他属性的整数值通过谷歌搜索其驱动程序密钥名称并不难找到,例如DEVPKEY_PciDevice_MaxLinkSpeed

这些属性适用于指定设备,而不是主板上的 PCI 插槽。WMI 似乎没有枚举有关 pci 端口的信息,尤其是未断开连接的端口。