Where was that script that ran a continuous vmotion for tests with #PowerCLI ?
— Maish Saidel-Keesing (@maishsk) January 15, 2012
The answers I got from @joerglew and @boukeg pointed me to VMJuggler written by Richard Garsthagen
But this was an MSI file and had to be installed as an application - so I said to myself - there has to be another way to do this.
So I wrote a small PowerCLI VMjuggler (the name and credits go all to Richard)
The basic functionality in the MSI was:
- Choose source Host
- Choose Destination Host
- Choose VM
- Display counter of the number of vMotions that have taken place
########################################################################### # # NAME: VMjuggler.ps1 # # AUTHOR: Maish Saidel-Keesing # # COMMENT: Based on the exe file from http://www.run-virtual.com/?dl_id=8 # This will move a vm between two hosts an endless loop until the script is stopped # It will display a counter of how many vmotions have been performed. # VERSION HISTORY: # 1.0 15/01/2012 - Initial release # ########################################################################### $hostA = Read-Host "Please enter the name of Host A" $hostB = Read-Host "Please enter the name of Host B" $vmname = Read-Host "Please enter the name of VM" $x = 0 While ($true) { Move-VM -VM $vmname -Destination $HostA | Out-Null $hostA,$hostB =$hostB,$hostA $x++ $x }
Annotations:
Lines 15-17 - Accept input to populate variables
Lines 19-21 - In an endless loop move the VM between hosts
Line 22 - I would like to thank Shay Levy for explaining to me how to switch the variables. The destination for the migration is always $hostA but each time the VM moves hosts - the destination must also change and this is the method to swap the values in the variables. A detailed explanation can be found here - http://tfl09.blogspot.com/2009/02/swapping-variables-with-powershell.html
Lines 23-24 - display the counter
Below is a Demonstration video of the script.
Hope you can make use of this.