VMjuggler–the PowerCLI version

I was tasked with testing the throughput of the vMotion network between two hosts - to see how much of the throughput was / could be used. Now I remembered that there was an application that someone had wrote to simulate vMotions between hosts - so I put the question out to Twitter

The answers I got from @joerglew and @boukeg pointed me to VMJuggler written by Richard Garsthagen 

Juggler

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:

  1. Choose source Host
  2. Choose Destination Host
  3. Choose VM
  4. 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 https://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 - https://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.