Are you still looking for a solution? If so can you clarify what you are trying to do?
this code doesn't work " Get-View -ViewType Datastore -SearchRoot $cluster.id" because datastores do not have a direct relationship with clusters. They are configured to hosts that can be in multiple clusters