How to get ESXi hosts Peripheral devices w/PowerCLi

Cover

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.

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

01.Get-VMHostPnicHba_SingleVMHost

  • 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

02.Get-VMHostPnicHba_Nolink

  • 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

03.Get-VMHostHba_FormatWWN

  • 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

04.Get-VMHostPnic_AutoNegotiation

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}.

05.Get-VMHostPnic_ClusterBaseline

  • 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 ', '}}

06.Get-VMHostHba_ClusterBaseline

  • 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.

07.Get-VMHostPnicHba_Verbose

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.

Summary

  • 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

08.Get-VMHostPnicHba_Alias

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s