Looks like Get-VMHost isn't placing any objects in the pipeline.
Are you sure
Get-cluster -Name "$cluster" | Get-VMHost
returns any VMHost objects ?
Looks like Get-VMHost isn't placing any objects in the pipeline.
Are you sure
Get-cluster -Name "$cluster" | Get-VMHost
returns any VMHost objects ?