Free Tool: Migrate Hyper-V Management OS Virtual Adapters To Another Switch3
Moving a virtual machine’s virtual adapter from one virtual switch to another is easy. It’s a drop-down box on the VM’s properties or a quick flip with Disconnect-VMNetworkAdapter and Connect-VMNetworkAdapter. None of this works for virtual adapters in the management operating system, though. Luckily for you, I’ve come up with a script that will do it. I even went and gave it a GUI.
How To Get It
Download right from this site: Migrate-VirtualAdapters.
How To Use It
- Make sure that you unblock the file. Right-click the file in Windows Explorer and go to Properties. Click the “Unblock” button. You can also use the Unblock-File cmdlet.
- The contents of the ZIP file, at least the .PS1 and .PSD1 file, need to find their way onto the Hyper-V host that contains the VMs to be changed.
- The execution policy on that host needs to be RemoteSigned or Unrestricted ( Set-ExecutionPolicy RemoteSigned ).
- The host the script is to run on must have at least two virtual switches or it won’t even open.
- Execute Migrate-VirtualAdapters.ps1 in a PowerShell session on that host. The PowerShell session must have elevated privileges.
What It Does
This script has a GUI and I hope it explains itself fairly well as it goes along.
The first screen is just a welcome box.
On the second screen, select the source and destination switch. Optionally, you can delete the source switch. The script won’t let you proceed if you pick the same switch for both.
On the third screen, check the adapters you want to move. If you are deleting the source switch, all others will be lost. Otherwise, they’ll be ignored.
On the fourth screen, you get a plain-language summary of what’s going to happen and a display of the PowerShell scripts that are going to run.
On the last page, it will just show success. Because, what could possibly go wrong? If you are unlucky enough to encounter any errors, they will be displayed here. If there are any problems during the move of the adapter, those will halt the entire process. For anything after, mainly recreating settings, the script will continue to run as much as it can and report whatever issues it runs into.
Please be aware that while the script will transfer any access-mode VLAN settings, it will not move any trunk settings. If this turns out to be a major sticking point I may revisit the subject in a later revision. Leave comments if you’re interested.