• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Crazy Consultant

Focus on cloud-native, AI and virtualization technologies

  • Home
  • Knowledge Library
    • Golden Kubestronaut Study Guide
    • Nutanix Study Guide
    • Nutanix Expert Challenge
    • Enterprise Kubernetes Platform Design Dimensions
    • Kubestronaut Challenge
    • Multiple‑Choice Exam Tips
  • News
  • Onyku®

ESXi get PCI device PowerCLI

September 17, 2015 by Christophe Calvet 1 Comment

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:

VMhostVMKernelNamePCIAddressDeviceClassNameDeviceNameSlotDescriptionVendorName
MyHost01vmhba0000:000:11.0IDE interfaceSB700 SATA Controller [IDE Mode]ATI Technologies Inc
MyHost01vmnic0000:001:00.0Ethernet controllerBroadcom NetXtreme II BCM5709 1000Base-TEmbedded NIC 1Broadcom Corporation
MyHost01vmnic1000:001:00.1Ethernet controllerBroadcom NetXtreme II BCM5709 1000Base-TEmbedded NIC 2Broadcom Corporation
MyHost01vmnic2000:002:00.0Ethernet controllerBroadcom NetXtreme II BCM5709 1000Base-TEmbedded NIC 3Broadcom Corporation
MyHost01vmnic3000:002:00.1Ethernet controllerBroadcom NetXtreme II BCM5709 1000Base-TEmbedded NIC 4Broadcom Corporation
MyHost01vmnic4000:022:00.0Ethernet controller82599 10 Gigabit Dual Port Network ConnectionPCI6Intel Corporation
MyHost01vmnic5000:022:00.1Ethernet controller82599 10 Gigabit Dual Port Network ConnectionPCI6Intel Corporation
MyHost01vmhba1000:023:00.0Fibre ChannelISP2532-based 8Gb Fibre Channel to PCI Express HBAPCI5QLogic Corp
MyHost01vmhba2000:023:00.1Fibre ChannelISP2532-based 8Gb Fibre Channel to PCI Express HBAPCI5QLogic 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

Filed Under: PowerCLI, PowerShell, VMware

Reader Interactions

Comments

  1. saravananmohan says

    June 13, 2017 at 7:19 am

    can you add to list s.no as well

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Connect with me

  • LinkedIn

Featured Credentials

Latest News

  • Onyku® at Norwegian VMUG 19 May 2025
  • NCM-MCI exam tips
  • Open Knowledge Diagrams with Mermaid and Git
  • Start of a journey
  • Banned from Lego – customer review