Tag Archives: storage vmotion

In case you ever need to empty out a datastore in you vmware environment, there is a nice little one-liner in PowerCLI for that: 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) Where “datastore1” is the datastore you want to empty out and “cluster1” is the cluster where the datastore is available. The command will move VMs from datastore1 to the datastore in cluster1 with the most available space (minimum 500GB)