Is there perhaps a ghost ESXi entry in one of the clusters?
The error seems to say that the $esx variable is $null.
Does the following show the same error?
Get-Cluster-PipelineVariable cluster |
ForEach-Object-Process {
Get-VMHost-Location $cluster-PipelineVariable esx |
ForEach-Object-Process {
Get-Datastore-VMHost $esx|
Select @{N='Cluster';E={$cluster.Name}},
@{N='VMHost';E={$esx.Name}},
Name
}
}