Powershell - PCI/PCIe 插槽占用

Bow*_*ark 7 motherboard pci-express powershell windows-10

鉴于以管理员身份运行 Windows Powershell 5.0 的 Windows 10 系统,我需要列出所有主板插槽和占用它们的设备名称(如果有)。

Win32_SystemSlot,与

Get-WmiObject -class "Win32_SystemSlot"
Run Code Online (Sandbox Code Playgroud)

似乎用奇怪的数字枚举插槽,而不是设备。

Win32_PnPEntity枚举设备,而不是插槽。

我想获得类似的东西

Slot            Device
---
PCIEX16_1       NVidia GeForce GTX 680...
PCIEX1_1        Empty
Run Code Online (Sandbox Code Playgroud)

是否可以?如果是,如何?

Stu*_*Stu 5

我碰巧知道您使用以下方法获得网卡:

> Get-NetAdapterHardwareInfo

Name                           Segment Bus Device Function Slot NumaNode PcieLinkSpeed PcieLinkWidth Version
----                           ------- --- ------ -------- ---- -------- ------------- ------------- -------
Wi-Fi                                0   2      0        0    4               2.5 GT/s             1 1.1
Ethernet                             0   3      0        0    5               2.5 GT/s             1 1.1
Run Code Online (Sandbox Code Playgroud)

使用上面@Lenniey 建议的模块 看起来您可以通过查找具有以“PCI 总线”开头的 LocationInfo 和非零 UINumber 的设备来找到设备的位置:

> Get-device | where {$_.LocationInfo -like 'PCI bus*' -and $_.UINumber -ne 0} | select Name, LocationInfo, UINumber

Name                                  LocationInfo                     UINumber
----                                  ------------                     --------
Realtek PCIe GBE Family Controller    PCI bus 3, device 0, function 0         5
Intel(R) Centrino(R) Wireless-N 2230  PCI bus 2, device 0, function 0         4
Run Code Online (Sandbox Code Playgroud)

在上面,我的网卡在插槽 5 中,而我的 wifi 在插槽 4 中。

然后,您可以将其与 PCI Express 根端口列表进行比较:

> Get-device | where {$_.Name -eq 'PCI Express Root Port'} | select Name,LocationInfo

Name                   LocationInfo
----                   ------------
PCI Express Root Port  PCI bus 0, device 28, function 5
PCI Express Root Port  PCI bus 0, device 28, function 0
PCI Express Root Port  PCI bus 0, device 28, function 4
Run Code Online (Sandbox Code Playgroud)

这会告诉你我有一个没有插入任何东西的第三个插槽,这与我在设备管理器中看到的一致。

警告; 我不是硬件专家,我只是根据我在我的机器上看到的东西猜到了这一点。

为了确认这不仅仅与网络适配器有关,如果我删除“UINumber -ne 0”上的过滤器,我可以看到连接到 PCI 总线的所有其他设备,但是,由于它们都是内置的,因此它们不会有一个插槽号:

Name                                                                              LocationInfo                      UINumber
----                                                                              ------------                      --------
Realtek PCIe GBE Family Controller                                                PCI bus 3, device 0, function 0          5
Intel(R) 6 Series/C200 Series Chipset Family USB Enhanced Host Controller - 1C26  PCI bus 0, device 29, function 0         0
PCI Express Root Port                                                             PCI bus 0, device 28, function 5         0
High Definition Audio Controller                                                  PCI bus 0, device 27, function 0         0
Intel(R) Centrino(R) Wireless-N 2230                                              PCI bus 2, device 0, function 0          4
Intel(R) Management Engine Interface                                              PCI bus 0, device 22, function 0         0
LPC Controller                                                                    PCI bus 0, device 31, function 0         0
PCI Express Root Port                                                             PCI bus 0, device 28, function 0         0
Memory Controller                                                                 PCI bus 0, device 0, function 0          0
PCI Express Root Port                                                             PCI bus 0, device 28, function 4         0
SM Bus Controller                                                                 PCI bus 0, device 31, function 3         0
Standard SATA AHCI Controller                                                     PCI bus 0, device 31, function 2         0
Intel(R) HD Graphics                                                              PCI bus 0, device 2, function 0          0
Thermal Control Device                                                            PCI bus 0, device 31, function 6         0
Intel(R) 6 Series/C200 Series Chipset Family USB Enhanced Host Controller - 1C2D  PCI bus 0, device 26, function 0         0
Run Code Online (Sandbox Code Playgroud)