Free Tool: Migrate Hyper-V Management OS Virtual Adapters To Another Switch

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

  1. 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.
  2. 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.
  3. The execution policy on that host needs to be RemoteSigned or Unrestricted ( Set-ExecutionPolicy RemoteSigned ).
  4. The host the script is to run on must have at least two virtual switches or it won’t even open.
  5. 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.

Adapter Migration Intro

Adapter Migration Intro

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.

Adapter Migration Switch

Adapter Migration Switch

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.

Adapter Migration Adapters

Adapter Migration Adapters

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.

Adapter Migration Summary

Adapter Migration Summary

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.

 

Altaro Hyper-V Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

7 thoughts on "Free Tool: Migrate Hyper-V Management OS Virtual Adapters To Another Switch"

  • Stephen Barash says:

    Eric, sorry but I don’t really get what this does. You say its easy to move virtual adapters, yet you can’t do this in the management operating system.

    But, if I use Hyper-V Manger’s Virtual Switch Manger to move virtual adapters, aren’t I already doing this via the management operating system?

    Thanks,
    Stephen

    • Eric Siron says:

      The built-in tools can only relocate virtual adapters connected to virtual machines. This script can only relocate virtual adapters connected to the management operating system.

  • I wrote something very similar for the new all GUI powershell Hyperv manager PSHVM30 and I even intergrated it with corefig 1.1. check it out pshvm.codeplex.com

Leave a comment or ask a question

Your email address will not be published. Required fields are marked *

Your email address will not be published. Required fields are marked *

Notify me of follow-up replies via email

Yes, I would like to receive new blog posts by email

What is the color of grass?

Please note: If you’re not already a member on the Dojo Forums you will create a new account and receive an activation email.