How to get ESXi hosts Peripheral devices w/PowerCLi


This time we will look at just two functions Get-VMHostPnic/Get-VMHostHba from my PowerCLi Vi-Module module to deal with ESXi hosts’ peripheral devices.

  • The Get-VMHostPnic for Physical Network Interface Controllers.

  • And Get-VMHostHba intended for Host Bus (fiber channel) Adapters.

UPDATE 19-Nov-2017 The Get-VMHostPnic from v.1.2:

  • The -Nolink parameter replaced with two new parameters -SpeedMbps and -Vendor.

  • Added three new properties: vSphere, DriverVersion and Firmware.

Get-VMHostPnic / Get-VMHostHba

  • Both the functions can receive ESXi host(s) from the pipeline.

Get-VMHost esxlab1 | Get-VMHostPnic | Format-Table -AutoSize
Get-VMHost ‘esxlab[1-3]’ | Get-VMHostHba | Format-Table -AutoSize


  • There is only one optional parameter -Nolink or its alias -Down, that returns disconnected adapters/controllers only.
Get-VMHost esxlab1 | Get-VMHostPnic -Nolink
Get-VMHost | Get-VMHostHba -Down | Format-Table -AutoSize


  • The Get-VMHostHba has one more optional parameter -FormatWWN. Just try it. The Intellisense is supported.
Get-VMHost esxlab1 | Get-VMHostHba -FormatWWN xx:xx:xx:xx:xx:xx:xx:xx
Get-VMHost esxlab1 | Get-VMHostHba -FormatWWN XXXXXXXXXXXXXXXX
Get-VMHost esxlab1 | Get-VMHostHba -FormatWWN xxxxxxxxxxxxxxxx


  • This trick will allow you to find all connected 1Gb network cards, that auto negotiated to 10 or 100Mb! The main reason for this is damaged network cable. As a result, the performance is degraded.
Get-VMHost | Get-VMHostPnic | ? { 1..999 -contains $_.SpeedMbps } | ft -au


Cluster troubleshooting

  • This small trick will help you to baseline and troubleshoot your clusters!
Get-Cluster VSAN1 | Get-VMHost | Get-VMHostPnic | ? {$_.SpeedMbps -eq 1000} | group VMHost | sort Name | select Name, Count, @{N='vmnic';E={(($_ |select -expand Group).PNIC) -join ', '}}
  • Yes, I agree, this one liner is a little long Emoj and may be difficult to understand, but it’s worth it.

  • Just copy-paste it AS IS and use your Cluster name Get-Cluster VSAN1 and NIC speed | ? {$_.SpeedMbps -eq 1000}.


  • The second cluster in above example does not look very good Emoj from the best practice perspective.

  • The same for HBA.

Get-Cluster VSAN1 | Get-VMHost | Get-VMHostHba | ? {$_.SpeedGbps -eq 4} | group VMHost | sort Name | select Name, Count, @{N='vmhba';E={(($_ |select -expand Group).HBA) -join ', '}}


  • Ups, probably one fiber cable is disconnected or damaged. Time to go down to the server room Emoj.

Verbose output

  • Both the functions support -Verbose parameter.

  • It shows some statistical info and function’s execution time.

Get-VMHost | Get-VMHostPnic -Verbose | Export-Csv -notype .\NIC.csv
Get-VMHost | Get-VMHostHba -Verbose | epcsv -NoTypeInformation .\HBA.csv
  • For Get-VMHostPnic the BMC states for Baseboard Management Controllers. These are IMM/iLO/iDRAC cards, that are not managed by VMkernel.


Returned properties

  • All returned properties are self-explained, I want to draw your attention only to some of them.

  • The Get-VMHostHbaWWN property is generated by format -f operator from another property. This is necessary data for fiber fabric zoning.

  • The Get-VMHostHbaModel and SpeedGbps pair can point at some kind of a problem if for example, 8Gb adapter synced at 4Gb on 8Gb fiber switch.

  • The adapter speed represented in different units. Get-VMHostPnic in SpeedMbps and Get-VMHostHba in SpeedGbps. The reason is that NIC speed can be lower than 1Gb, but HBA cannot.

  • Both the functions – Vendor property. Actually this data does not exist! I generate it at runtime from the Driver property. If for some reason the Vendor equal Unknown, please write in the comments your Driver and I’ll try to fix it in the feature releases. Thanks in advance.


  • For more details about the functions, please take a look at the content based help and examples.

Get-Alias –Definition Get-VMHostPnic
gal –d Get-VMHostHba
Get-Help Get-VMHostPnic -Full
Get-Help Get-VMHostHba -Examples
Get-Help Get-VMHostPnic -Parameter Nolink
Get-Help Get-VMHostHba -Parameter FormatWWN


You may also like:

Get-VMHostGPU – Get ESXi GPU info
Get-VMHostFirmwareVersion – Get ESXi servers BIOS/Firmware version
Enable/Disable-VMHostSSH – Enable/Disable SSH on all ESXi hosts in a cluster
Connect-VMHostPutty – Open multiple putty sessions to ESXi hosts with no password

One thought on “How to get ESXi hosts Peripheral devices w/PowerCLi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s