A few blogs ago I showed you how to migrate from Standard Virtual Switch to Logical Switch in Virtual Machine Manager.
In today’s post I will show you how to migrate your virtual machines from an existing logical switch to another logical switch.
But before start doing that, let’s see in what scenario you might require this migration.
1- You have upgraded your Hyper-V host with higher network adapters and now you want to move all your VMs workload over the new NICs.
2- You are using converged virtual network within Hyper-V deployments that is managed by System Center Virtual Machine Manager, and now you need to move all your VMs traffic off the converged vSwitch and use a dedicated logical switch.
More information on how to create a Logical Switch in VMM.
In order to move your virtual machine from one logical switch to another one is very simple.
To choose a logical switch
Open the VM and Services workspace.
Choose any host group, and then select the desired virtual machine.
On the Virtual Machine tab, click Properties.
The Virtual Machine window properties opens.
Choose the Hardware Configuration, and then browse to Network Adapters.
Select the desired Virtual Network Adapter, and then change the Logical Switch as showing in below figure.
Select the Logical Switch for virtual machines in VMM. (Image Credit: Charbel Nemnom)
Now the challenge is, what if you need to migrate 50 VMs and each VM has multiple vNICs and each is on different VLAN?
Because when you change the Logical Switch in the UI, you need to select again the port classification and enable the VLAN ID.
Changing the Logical Switch for virtual machines in VMM. (Image Credit: Charbel Nemnom)
This indeed a long homework!
So what is the solution then?
The answer is PowerShell of course
I have created the following tool that will help you to migrate all Virtual Machines on a particular Hyper-V host from an existing logical switch to another logical switch, while preserving all the existing configuration:
<# .SYNOPSIS Migrating Virtual Machines from Logical Switch to another Logical Switch in Virtual Machine Manager. .DESCRIPTION Migrating Virtual Machines from Logical Switch to another Logical Switch in Virtual Machine Manager. .NOTES File Name : VMM-LSMigration.ps1 Author : Charbel Nemnom Date : 15-04-2020 Version : 1.1 Requires : PowerShell Version 3.0 or above OS : Windows Server 2012, 2012 R2, 2016, 2019 Component : System Center Virtual Machine Manager 2012 R2, 2016, 2019 .LINK To provide feedback or for further assistance please visit:
Do you have any other scenarios? please feel free to leave a comment below.
Hope this helps!