ESX Hardware

Audit and Manage ESXi Hosts with PowerCLI

It’s not enough in this day and age for administrators to oversee their virtual environments. Increasingly I hear more about the need for updating the ESXi hosts’ drivers and firmware during maintenance windows. I get it, I completely understand this need. So how does an admin keep up on what hardware all of his VMs are running on? What if you need to check the hardware to compare it against the Hardware Compatibility List for a new version?

We’ve made this much easier! Read on!

Introducing Two New Cmdlets

In PowerCLI 6.0 R2 we introduced two new cmdlets to help admins have visibility into the physical hardware their virtual environments are running on.

Get-VMHostHardware

Get-VMHostHardware allows users to query their ESXi hosts and return specific information about each machine. Some of the key information returned includes:

  • VMHost Name
  • Manufacturer
  • Model
  • Serial Number
  • Asset Tag
  • BiosVersion
  • CPU Model
  • CPU Count
  • CPU Core Count Total
  • Mhz Per CPU
  • NicCount
  • and more…

vmhosthardware

This can be very beneficial when running a report on the hardware the virtual environment is running on. Information from this cmdlet, like the Bios Version, can be very helpful when planning the next maintenance window for specific hosts. Now you have two options for determining which hosts need to be updated. First, exporting all results to CSV and then filtering on BIOS version or other property. Second, modify the PowerCLI command to filter results to return exactly the data that you want to see. For example, you may use the following code to bring back each unique BIOS Firmware version across your hosts:

HardwareSorted

We use the ConnectionState property because the Get-VMHostHardware cmdlet cannot query against a disconnected host, so rather than seeing an error for any host that is not connected, we take care of it at this stage.

The additional information provided by this cmdlet will allow you to verify CMDB data as well as feed reports back to CMDBs or other groups in your company.

Get-VMHostPciDevice

Want a cmdlet that will return all PCI Devices on your ESXi Host? Look no further! The new Get-VMHostPciDevice cmdlet will return all the information you ever wanted about your ESXi Host devices. It operates just like the previous cmdlet so you will need to make sure that the hosts are powered-on and connected before running this cmdlet otherwise it will return an error for any host not in this desired state. I find it easiest to export this information to either a CSV or use Out-GridView to pull this information into a nicely formatted window to look through. The code below can be used to bring back all PCI Device information on all ESXi Hosts in your vCenter

image

You could take this information and export it to CSV and save it for future reference or support.

To learn more about these two cmdlets, use the Get-Help cmdlet to see examples or read more about them in the online cmdlet reference here.

Have you updated to PowerCLI 6.0 R3 yet? Why not? Did you know it supports all the way back to vCenter Server 5.0? Download it today from here and gain the latest benefits.