One of the challenges in managing a large VMware Infrastructure is keeping all ESX Servers within a cluster equal. This is essential for having vmotion capabilities and therefore essential for a solid HA configuration. I have showed you earlier how to add the LUN Count for each ESX Server to your VI Client. This allows you to spot differences quickly. But finding exactly which datastores are missing on which ESX Server can be a bigger challenge.
Here are some small functions that can help you determine where the major differences are.
Comparing datastores:
function Compare-VMHostDatastores
{
param([string]$host1,[string]$host2)
$a = Get-VMHost $host1 | Get-Datastore | %{$_.Name}
$b = Get-VMHost $host2 | Get-Datastore | %{$_.Name}
Compare-Object $a $b
}
Compare-VMHostDatastores esxServer1 esxServer2
InputObject SideIndicator
———– ————-
esxServer1_Local <=
esxServer2_Local =>
DATASTORE_TEST1 =>
And comparing Port Groups:
function Compare-VMHostPortgroups
{
param([string]$host1,[string]$host2)
$a = Get-VirtualPortGroup (Get-VMHost $host1) | %{$_.Name}
$b = Get-VirtualPortGroup (Get-VMHost $host2) | %{$_.Name}
Compare-Object $a $b
}
Compare-VMHostPortgroups esxServer1 esxServer2
InputObject SideIndicator
———– ————-
PortGroup_TEST <=
Internal <=
Maybe you prefer to go the other way around and check to which ESX servers a specific datastore is attached?
function Get-DatastoreHosts
{
param([string]$datastore)
Get-VMHost -Datastore (Get-Datastore $datastore) | Sort Name | %{$_.Name}
}
PS D:Scripts> Get-DatastoreHosts DATASTORE_TEST1
esxServer2
esxServer3
Thank Microsoft for Powershell and the Compare-Object cmdlet!
Hugo