More migration/upgrade stuff… As part of a larger migration strategy, I needed to migrate whole datastores. Literally Terabytes of VM data, while sVMotion did all the heavy lifting. I still needed a control script to manage this process for me. This script ran successfully for over three days on one of my larger datastores. Faithfully, moving my VM’s two by two!
$SourceDS = Get-Datastore 'VMData1'
$DestinationDS = Get-Datastore 'VMData0'
$MaxConcurrent = 2
#Keep at least 10% freespace in the datastore
$buffer = ($DestinationDS.CapacityMB * .1) * 1048576
$DestView = Get-View -VIObject $DestinationDS -Property Info
$SourceView = Get-View -VIObject $SourceDS -Property vm
While ($DestView.Info.FreeSpace -gt $buffer -and $SourceView.VM.count -ge 1)
$SourceDS | Get-VM | Select-Object -First $MaxConcurrent | Move-VM -Datastore $DestinationDS -RunAsync | Wait-task
Honestly I completed this over a month ago, but I consider these little scripts I write to be too simple to post… My drafts folder is full of stuff like this. On the one hand I want to post for my own use, but I can search my drafts for that. So I ask you, do you get any value out of these one off solutions? Please, don’t pad my ego… If you don’t find this kind of stuff useful don’t pretend. I have my documentation, I want to know if you would like access to it?
See ya’ll at VMworld