Compare two or more ESXi hosts w/PowerCLi

Cover

The Compare-VMHost function from my PowerCLi Vi-Module allows you to compare two individual ESXi hosts one to another or compare group of hosts, for example, all HA/DRS Cluster members with one reference host.

Mandatory parameters

The function has two mandatory parameters.

  • -ReferenceVMHost – the reference host that will be compared to the others.

  • -​DifferenceVMHost – host(s) for comparison.

Both parameters take the objects returned by the Get-VMHost cmdlet. Moreover, compared hosts may be passed through the pipeline.

Get-Help Compare-VMHost –Parameter ReferenceVMHost
Get-Help Compare-VMHost –Parameter DifferenceVMHost
Get-Cluster PROD | Get-VMHost | Compare-VMHost –Compare VIB –ReferenceVMHost (Get-VMHost ‘esxprd1.*’)

–Compare parameter

What exactly will be compared? It is controlled by –Compare parameter. The parameter is positional and can be safely omitted. At this moment, the function can compare the following:

  • Portgroups (Networks – both from Standard vSwitch and Distributed VSwitch)

  • Datastores

  • Shared Datastores

  • SCSI Devices (aka Canonical Names «naa.*»)

  • SCSI LUN (LUN ID)

  • NTP settings

  • VIB (vSphere Installation Bundles)

01.Compare-VMHost_CompareParam

Comparison rules

  • Powered off, Disconnected and inaccessible (Not Responding) hosts are skipped from comparison with no output. To be notified about these hosts, use -Verbose parameter.
Get-VMHost | Compare-VMHost VIB –ref (Get-VMHost ‘esx1.*’) -Verbose
  • The compare is case sensitive (it is very important when comparing VSS Portgroups, especially when them contain VMkernel ports).

  • When compare NTP settings the NTP servers order is matter. For example, ntp1, ntp2 is not the same as ntp2, ntp1, as well as ntp1 is not the same as NTP1. To set NTP settings please use my another Set-VMHostNtpServer function.

  • When compared hosts are the same (no difference in compared criteria), the Compare-VMHost returns no output.

02.Compare-VMHost_TruncateHideReference

Function output

The returned objects have four properties:

Property Description
–Compare parameter’s value (what do you compare) Unique compared object name
VMHost ESXi host name that owns this unique object
Reference Is ESXi host in VMHost property reference host or not – Boolean value
Difference If Reference is True, this property will contain compared difference ESXi host name, that does not have this object

Optional parameters

The function has also two optional, but very cool parameters.

  • -Truncate. ESXi name usually is FQDN. The –Truncate switch will cut a domain name from FQDN to shorten the property’s length.

  • -HideReference. This switch will hide the Reference host related objects from the output.

03.Compare-VMHost_NTP

Use cases

In large environments, it is important to monitor the homogeneity. One of the function use cases is a HA/DRS cluster baselining. You can compare a whole cluster with a reference host (something like Host Profiles, but with no need in Enterprise Plus license Emoj).

Get-Cluster DEV | Get-VMHost | Compare-VMHost VIB –ref (Get-VMHost ‘esxdev1.*’) –Verbose
Get-Datacenter North | Get-VMHost | Compare-VMHost NTP –ref (Get-VMHost ‘esx1.contoso.com’) –Truncate –HideReference
Get-VMHost | Compare-VMHost LUN –ref (Get-VMHost ‘esx1.*’) –Truncate

04.Compare-VMHost_Portgroup

In above example we can see, that all hosts have no some Portgroups that do present on the reference host. If say this Portgroup contains VMotion enabled VMkernel port, the vMotion will fail! In the case of common Portgroup, VMs only Emoj will be affected.

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

Get-Help Compare-VMHost -Full
Get-Help diffesx -Examples
Get-Help Compare-ViMVMHost –Parameter Truncate

Take a note, some function parameters (as well as the function itself) have short aliases for more convenience, for example the -ReferenceVMHost have the -ref alias.

Get-Alias –Definition Compare-VMHost
Get-Help Compare-VMHost –Parameter ReferenceVMHost

You may also like:

Get-VMHostGPU – Get ESXi GPU info
Get-VMHostFirmwareVersion – Get ESXi servers BIOS/Firmware version
Set-VMHostNtpServer – Configure ESXi hosts NTP settings

One thought on “Compare two or more ESXi hosts w/PowerCLi

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