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.
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.*’)
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)
SCSI Devices (aka Canonical Names «naa.*»)
SCSI LUN (LUN ID)
VIB (vSphere Installation Bundles)
- Powered off, Disconnected and inaccessible (Not Responding) hosts are skipped from comparison with no output. To be notified about these hosts, use
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, ntp2is not the same as
ntp2, ntp1, as well as
ntp1is 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-VMHostreturns no output.
The returned objects have four properties:
|–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|
The function has also two optional, but very cool parameters.
-Truncate. ESXi name usually is FQDN. The
–Truncateswitch 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.
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 ).
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
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 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
Get-Alias –Definition Compare-VMHost Get-Help Compare-VMHost –Parameter ReferenceVMHost