Using PowerShell to Live Migrate to a Computer with a Different Virtual Switch
So far this week I have shown you how to register and how to import virtual machines with configuration problems using PowerShell. However, the question I most often hear is this one: how do I use PowerShell to live migrate a virtual machine to another computer – where the virtual switch names do not match?
Once again – the answer is: “Use Compare-VM”
Here you can see that I try and use Move-VM to live migrate a virtual machine, and I get an error because the virtual switch names do not match. And just like in the other cases, I call Compare-VM and give it the same parameters as when I tried to use Move-VM.
After doing this I just need to fix the incompatibilities and pass the results into Move-VM.
Cheers,
Ben
Comments
Anonymous
January 12, 2015
Is there any command, we can set the parameter to use destination virtual switch during the live migration. for eg: VM running on the host with VSW1 and destination host virtual swtich VSW2. As we are telling the DestinationHost, can we set Destination VirtualSwtich...?Anonymous
November 16, 2017
I'm trying to use Compare-VM when migrating a VM to a host with a different virtual switch as you describe, but not having much luck. When I run the command below on the Hyper-V source server, I get an error 'Connect-VMNetworkAdapter: Hyper-V was unable to find a virtual switch with the name "Hyper-V Network"'. $VMReport.Incompatibilities | ?{$.messageid -eq 33012}| %{connect-vmnetworkadapter $.Source -switchname "Hyper-V Network"}I know this is an old post, but if the author or anyone else has run into this or has a suggestion as to where I'm going wrong, I'd appreciate it. Thanks!