Would something like this work for you?
Get-VMHost -Name esx1*, esx2* -PipelineVariable esx |
ForEach-Object -Process {
Get-Datastore -RelatedObject $esx -PipelineVariable ds |
ForEach-Object -Process {
$storSys = Get-View -Id $esx.ExtensionData.ConfigManager.StorageSystem
$storSys.UnmountVmfsVolume($ds.ExtensionData.Info.vmfs.uuid)
}
}