So you got a new SAN, or you bought some more disk and attached it. Storage VMotion is great - but who wants to sit around and click and migrate tens or hundreds of VMs?
I did a little googling, because I'm lazy. I didn't find anything (but I didn't look that hard) that did what I wanted it to do. I did find the following one-liner here.
Get-VM -Datastore SOURCEDATASTORE| Move-VM -Datastore DESTINATIONDATASTORE -DiskStorageFormat thin
This one liner is great, but the problem is that it will slam your storage system by executing all the svmotions at once. That's okay if you have two or three VMs, but presumably you bought more storage because of a controller or disk constraint, and this will further deteriorate your storage performance.
Well, how do we solve that? Let's just move one VM at a time.
If you want to move all the VMs from a datastore sequentially and one at a time, take this script block, modify the variables for your environment, save it as a .ps1, and you'll be all set:
connect-viserver vcenter.domain.tld
$sourcedatastore = "SOURCEDATASTORE"
$destinationdatastore = "DESTINATIONDATASTORE"
$vms = Get-VM -Datastore $sourcedatastore
foreach($vm in $vms){
Move-VM -VM (Get-VM -Name $vm) -Datastore $destinationdatastore -DiskStorageFormat thin
}
This will move all the VMs, but one at a time...further delaying the onset of your carpal tunnel syndrome. You can thank me another day :)