This one seems to work so far.
But I have to add that I would need to find the VMs on several datastores. Like all datastores starting with TEST*.
Using this doesnt seem to work:
$ds = Get-Datastore "TEST*"
Get-Cluster Test| Get-VM | where {$_.DatastoreIdList -contains $ds.ExtensionData.Moref}
But this finds the correct datastores:
Get-Datastore "TEST*"