PowerCLI: Evacuating a datastore

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....

September 11, 2014 · nerenther