Migration script for VM´s moving to Hyper-v 2012 from 2008r2 with VMM

As you might have been reading on my blog about the implementation of the SCVMM 2012 SP1 I have been doing at a customer and the challenges with networking and hosts.

Now the turn has come to migrate those VM´s that reside on the old 2008 R2 cluster to the new shiny Hyper-V 2012 cluster. The approach this time has been to use the VMM and migrate them between the clusters.

VMM 2012 SP1 has some shortcomings when it comes to different configured clusters and their networks. With a bit of crafty PowerShelling I solved that.

So the error was that I could not set the network that I wanted in the migration on the target.. In the VMM Console I get a error and could not continue :

Screen Shot 2013-09-26 at 09.47.36

Then I thought that its maybe an issue in the GUI and can be override in the PowerShell console but NOOOO there exist no parameter for setting the virtual switch 🙁

Screen Shot 2013-09-26 at 09.44.49

So I wrote a little script function that first get the VLAN information on the network adapters connected on the VM and then disconnects the virtual network adapters for the VM before migration and then the migration succeeds  🙂 and after the migration I connect the virtual network adapters to the VM networks on the new logic switch that correlates to the right VLAN from the source.

from a previous bad experience when trying to migrate VM´s between versions of Hyper-V on VMM with snapshots (Checkpoints) I added a check in the function to not allow migration of VM´s that have active snapshots.

Screen Shot 2013-09-26 at 14.28.54

And here is the script (will do some more thorough testing and add some functionallity but it gives you the idea )

 

Comments

Maneesh
Reply

Thanks for sharing the powershell script.

Leave a comment

name*

email* (not published)

website