Extract via PowerCLI PCI information associated to vmnic,vmhba,vmgfx ESXi devices including the slot description at the rear of the server.
Have you ever been in a situation where you need information regarding the cabling of an ESXi host without having the possibility to physically check the rear of the server?
The script below may help you in that case.
Get-VMhostPCIDevice.ps1
function Get-VMhostPCIDevice{ <# .DESCRIPTION This function use a PowerCLI vmhost as a parameter and via Get-esxcli get information for the following PCI devices: Network device - vmnic Storage adapter - vmhba Graphic device - vmgfx It works only with ESXi version 5.0.0 or above. .NOTES Author: Christophe Calvet Blog: http://thecrazyconsultant.com/ .PARAMETER VMHost One or many PowerCli VMHost object .EXAMPLE Get-vmhost -name "MyHost01" | Get-VMhostPCIDevice | ogv #> param( [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl]$VMhost ) process{ Try{ $esxcli = get-esxcli -vmHost $VMhost $PciInformation = $esxcli.hardware.pci.list() | where {$_.VMKernelName -like "vmhba*" -OR $_.VMKernelName -like "vmnic*" -OR $_.VMKernelName -like "vmgfx*"} $PciInformation| foreach { $Output = New-Object -Type PSObject -Prop ([ordered]@{ 'VMhost' = $VMhost 'VMKernelName' = $_.VMKernelName 'PCIAddress' = $_.Address 'DeviceClassName' = $_.DeviceClassName 'DeviceName' = $_.DeviceName 'SlotDescription' = $_.SlotDescription 'VendorName' = $_.vendorname }) Return $Output } } Catch{ Write-error $_ } } }
Result with a Dell PowerEdge R815:
VMhost | VMKernelName | PCIAddress | DeviceClassName | DeviceName | SlotDescription | VendorName |
---|---|---|---|---|---|---|
MyHost01 | vmhba0 | 000:000:11.0 | IDE interface | SB700 SATA Controller [IDE Mode] | ATI Technologies Inc | |
MyHost01 | vmnic0 | 000:001:00.0 | Ethernet controller | Broadcom NetXtreme II BCM5709 1000Base-T | Embedded NIC 1 | Broadcom Corporation |
MyHost01 | vmnic1 | 000:001:00.1 | Ethernet controller | Broadcom NetXtreme II BCM5709 1000Base-T | Embedded NIC 2 | Broadcom Corporation |
MyHost01 | vmnic2 | 000:002:00.0 | Ethernet controller | Broadcom NetXtreme II BCM5709 1000Base-T | Embedded NIC 3 | Broadcom Corporation |
MyHost01 | vmnic3 | 000:002:00.1 | Ethernet controller | Broadcom NetXtreme II BCM5709 1000Base-T | Embedded NIC 4 | Broadcom Corporation |
MyHost01 | vmnic4 | 000:022:00.0 | Ethernet controller | 82599 10 Gigabit Dual Port Network Connection | PCI6 | Intel Corporation |
MyHost01 | vmnic5 | 000:022:00.1 | Ethernet controller | 82599 10 Gigabit Dual Port Network Connection | PCI6 | Intel Corporation |
MyHost01 | vmhba1 | 000:023:00.0 | Fibre Channel | ISP2532-based 8Gb Fibre Channel to PCI Express HBA | PCI5 | QLogic Corp |
MyHost01 | vmhba2 | 000:023:00.1 | Fibre Channel | ISP2532-based 8Gb Fibre Channel to PCI Express HBA | PCI5 | QLogic Corp |
The column “SlotDescription” is the most interesting.
Without having a physical access to the server, it is possible to identify in this case that vmnic4 and 5 are associated to a 10GB dual port Network card connect to the PCI6 slot at the rear of the server.
Port0 on the card will be associated to vmnic4 and port1 to vmnic5.
There is one extra challenge however, PCI cards are sometime upside down, so it is not possible to know directly if port0 will be the left or the right port of the network card.
Kmown limitation:
This script will work only with ESXi version 5.0.0 or above. (Linked to availability of “esxcli hardware pci list”)
It is necessary to have enough rights to execute Get-esxcli on the target host
Notes:
The “esxcli hardware pci list” provides much more information than in the table above.
It will be quite easy to modify the script to extract them as well or to remove the filter “vmhba/vmnic/vmgfx only”.
I do not have a server with a graphic device to test vmgfx but i guess that it will work in the same way as vmhba and vmnic.
Related topics:
Mapping PCI slot numbers to guest-visible PCI bus topology
How VMware ESXi 5.5 and 6.0 determine the order in which names are assigned to devices
can you add to list s.no as well