In this post I will show you how to move a Hyper-V Virtual Machine from one Hyper-V Server to another without
the use of Live Migrations. If find this technique very useful when I am swapping out hardware and just need
a simple process to follow to get the guest instances stood up on the new farm.

This can of course be fully automated but the purpose of this exercise will be to show how to do it manually.


Here are the steps I generally follow:

  1. Build the new Windows 2012 or R2 Hyper-V Server
  2. Download and Patch with all updates from Microsoft (The purpose of this is not to show all the updates)
  3. Download and install the latest Firmware and Drivers for the Hypervisor

Run this NIC Configuration Script. I run this on all of my Hyper-V implementations in production

Here is the source for the script:

<#

Script name: Hyper-V_ProductionScript_V1.0.ps1

Created:     2014-04-03

Version:     1.0

Author Dave Kawula

Homepage: Comming soon … http://www.osdweek.com / http://www.checkyourlogs.com /

Homepage: http://www.triconelite.com

Disclaimer:

This script is provided “AS IS” with no warranties, confers no rights and

is not supported by the authors or DeploymentArtist.

Author – Dave Kawula

Twitter: @DaveKawula

Blog : (Coming Soon) http://www.checkyourlogs.com / www.nitandgritofit.com

This Script will perform a base configuration of the Network Adapters on a new Hyper-V Host Server

THis Script has been used in production and only lacks some error control at this time.

It will work as is — You just need to watch your Adapter Configuration and what you want to team up…

Ethernet, Ethernet 2 etc.

#>

#start-transcript -path c:\post-install\001-NetworkConfig.log

#Create the NIC Team

New-NetlbfoTeam
PRODVLAN
“Ethernet”, “Ethernet 2”
–verbose

#Get the Status of the Network Adapters

Get-NetAdapter
|
Sort
Name

#Create the new Hyper-V Vswitch VSW01

new-vmswitch
“VSW01”
-MinimumBandwidthMode
Weight
-NetAdapterName
“PRODVLAN”
-verbose

#Check the Bindings

Get-NetadapterBinding
|
where {$_.DisplayName –like
“Hyper-V*”}

#Check the Adapter Settings

Get-NetAdapter
|
sort
name

#Now Create the Converged Adapters

Add-VMNetworkAdapter
–ManagementOS
–Name
“LM”
–SwitchName
“VSW01”
–verbose

Add-VMNetworkAdapter
–ManagementOS
–Name
“ISCSI”
–SwitchName
“VSW01”
–verbose

Add-VMNetworkAdapter
–ManagementOS
–Name
“CLUSTERCSV”
–SwitchName
“VSW01”
–verbose

#Review the NIC Configuration Again

Get-NetAdapter
|
Sort
name

#Rename the HOST NIC

Rename-NetAdapter
–Name
“VEthernet (VSW01)”
–NewName
“vEthernet (Host)”
–verbose

#Review the NIC Configuration Again

Get-NetAdapter
|
Sort
name

#Set the weighting on the NIC’s

Set-VMNetworkAdapter
–ManagementOS
–Name
“CLUSTERCSV”
–MinimumBandwidthWeight
40

Set-VMNetworkAdapter
–ManagementOS
–Name
“LM”
–MinimumBandwidthWeight
20

Set-VMNetworkAdapter
–ManagementOS
–Name
“ISCSI”
–MinimumBandwidthWeight
10

Set-VMNetworkAdapter
–ManagementOS
–Name
“VSW01”
–MinimumBandwidthWeight
5

Set-VMNetworkAdapterVlan
-ManagementOS
-VMNetworkAdapterName
“ISCSI”
-Access
-VLanID
10

Set-VMNetworkAdapterVlan
-ManagementOS
-VMNetworkAdapterName
“LM”
-Access
-VLanID
1000

Set-VMNetworkAdapterVlan
-ManagementOS
-VMNetworkAdapterName
“CLUSTERCSV”
-Access
-VLanID
1000

#Stop-transcript

  1. Ok so let’s start there we will take a new Windows Server 2012 R2 Server as our Target Server the only role
    that has been added thus far is the Hyper-V Role. DO NOT CREATE the VSWITCHES in the WIZARD. We will
    Do that ourselves with this script

    As we can see from the Screen Shot above we have a default Networking Stack Configured at this time

    For this Lab Environment I made a few changes to my default script

    I just change the script to run against a Single Ethernet Adapter and Comment out the bottom where the VLAN’s

    Are defined.

     

    NOTE: The Script will fail to run without the Hyper-V Role being installed first. This is because it relies on
    the Powershell Module for Hyper-V to create the VSwitches and Virtual Adapters.

OLD CODE NEW CODE

New-NetlbfoTeam
PRODVLAN
“Ethernet”, “Ethernet 2”
–verbose

New-NetlbfoTeam
PRODVLAN
“Ethernet”
–verbose

Set-VMNetworkAdapterVlan
-ManagementOS
-VMNetworkAdapterName
“ISCSI”
-Access
-VLanID
10

Set-VMNetworkAdapterVlan
-ManagementOS
-VMNetworkAdapterName
“LM”
-Access
-VLanID
1000

Set-VMNetworkAdapterVlan
-ManagementOS
-VMNetworkAdapterName
“CLUSTERCSV”
-Access
-VLanID
1000

#Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName “ISCSI” -Access -VLanID 10

#Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName “LM” -Access -VLanID 1000

#Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName “CLUSTERCSV” -Access -VLanID 1000


  1. I have staged the Script in c:\Post-Install\001-NICConfig\Hyper-V_ProdNetworkScript_V1.0.PS1
  2. First open an Administrative PowerShell Prompt
  3. Then type Set-ExecutionPolicy unrestricted
  4. The type cd \post-isntall\001-NICConifg
  5. The type .\Hyper-V_ProdNetworkScript_V1.0.PS1 When Prompted say Yes
  6. Type ncpa.cpl to open the Networking Control Panel


    You will see that we have a production ready Networking Configuration now setup for this Hyper-V Host. Obviously your configurations
    will vary. But this is a great starter script. Hope you Enjoy!!