To clarify, you have multiple target datastores and you want to check if there is sufficient free space available before the move ?
And the VM should be moved to the datastore with the most free space ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could do something like this:
Get-VM -Datastore "datastore1" | Move-VM -Datastore (Get-VMHost -Location 'cluster1' | Select-Object -First 1 | Get-Datastore | Where-Object {($_.Name -ne 'datastore1') -and ($_.FreeSpaceGB -gt '500')} | Get-Random)
This will move VMs from datastore1 to a random datastore in cluster1 with more than 500GB space available.
Swap out datastore1 and cluster1 with the datastore you are moving from and the cluster, and 500 with the amount of free space (in GB) you want the destination datastore to have.
In case you don't want to move to a random datastore, but always use the one with the most free space available, you can swap out Get-Random with Sort-Object FreeSpaceGB -Descending | Select-Object -First 1.
Like this:
Get-VM -Datastore "datastore1" | Move-VM -Datastore (Get-VMHost -Location 'cluster1' | Select-Object -First 1 | Get-Datastore | Where-Object {($_.Name -ne 'datastore1') -and ($_.FreeSpaceGB -gt '500')} | Sort-Object FreeSpaceGB -Descending | Select-Object -First 1)