How To Migrate Logical Networks from VMM to VMM with PowerShell #VMM #SCVMM #HyperV #PowerShell

3 Min. Read

In this article, we will show you how to migrate logical networks from one SCVMM instance to another one.

Introduction

VMM permits us to create a logical grouping for all the networks which are involved in the Datacenter configuration. Once you create the logical grouping, VMM is able to manage the tasks of keeping the respective networks up-to-date and always in sync.

To implement Software Defined Networks in VMM, first, you need to prepare the following building blocks:

  • Logical Networks
    • Network Sites:  VLAN ID | Network Subnets
    • IP Pools: IP Address Range | VIPS | Gateway | DNS
  • VM Networks
  • Port Profiles
  • Logical Switches

Unfortunately, the networking side of VMM was always a pain to deal with.

> Learn how to install System Center Virtual Machine Manager 2022 on Windows Server 2022.

Migrate Logical Networks

Let’s see how to migrate logical networks from one VMM instance to another one.

After working with an implementation of a new VMM 2016, I have been trying to read and document all the networks that were created with the old VMM server.

My old VMM server Logical Networks looks like this:

SCVMM Logical Networks
SCVMM Logical Networks

I still want to get all the network information that I had in the old VMM server to be able to create new virtual networks with the same network information on the second VMM server.

Here is a simple PowerShell script that helped me to migrate all Logical Networks, Network Sites, IP Pools, and VM Networks from one VMM server to another VMM server:

<#
.SYNOPSIS
Migrate VMM Logical Networks, IP Pools, VM Networks from VMM to VMM.

.DESCRIPTION
Migrate VMM Logical Networks, IP Pools, and VM Networks from one VMM server to another VMM server.
.NOTES
File Name : Migrate-VMMLogicalNetworks.ps1
Author    : Charbel Nemnom
Version   : 2.0
Requires  : PowerShell Version 4.0 or above
OS        : Windows Server 2012 R2, Windows Server 2016
VMM       : SCVMM 2012 R2, SCVMM 2016 

.LINK
To provide feedback or for further assistance please visit: https://charbelnemnom.com

.PARAMETER VMMServerToRead
The name of the First VMM Server
.PARAMETER VMMServerToCreate
The name of the Second VMM Server

.EXAMPLE
.\Migrate-VMMLogicalNetworks -VMMServerToRead <VMMServer01> -VMMServerToCreate <VMMServer02>
This example will migrate all Logial Networks, IP Pools and VM Networks
from one VMM server to another VMM server.

#>

[CmdletBinding()]
param (
    [Parameter(Mandatory, Position = 0, HelpMessage = 'First VMM Server Name')]
    [Alias('VMM Server 01')]
    [String]$VMMServerToRead,

    [Parameter(Mandatory, Position = 1, HelpMessage = 'Second VMM Server Name')]
    [Alias('VMM Server 02')]
    [String]$VMMServerToCreate  
    
)

Try {
Write-Verbose "Read First VMM Server: $($VMMServerToRead)"
$VMMToRead   = Get-SCVMMServer -ComputerName $VMMServerToRead
} Catch { 
  Write-Warning -Message "Unable to connect to $($VMMServerToRead)"
  Break
}

Try {
Write-Verbose "Read Second VMM Server: $($VMMServerToCreate)"
$VMMToCreate = Get-SCVMMServer -ComputerName $VMMServerToCreate
} Catch {
  Write-Warning -Message "Unable to connect to $($VMMServerToCreate)"
  Break
}

Write-Verbose "Read All Logical Networks from $($VMMServerToRead)"
$ReadLogicalNetworks = Get-SCLogicalNetwork -VMMServer $VMMToRead

# //Read the LN and create accordingly
ForEach ($ReadLogicalNetwork in $ReadLogicalNetworks)
{
     Write-Verbose "Create Logical Network: $($ReadLogicalNetwork.Name) on $($VMMServerToCreate)" 
     $LNToCreate = New-SCLogicalNetwork $ReadLogicalNetwork -VMMServer $VMMToCreate   
     
     # //Read the LND and create accordingly
     $LNDs = Get-SCLogicalNetworkDefinition -LogicalNetwork $ReadLogicalNetwork -VMMServer $VMMToRead
     ForEach ($LND in $LNDs) {
     Write-Verbose "Create Network Site: $($LND.LogicalNetwork.Name) on $($VMMServerToCreate)" 
     $LNDToCreate = New-SCLogicalNetworkDefinition -VMMServer $VMMToCreate -LogicalNetwork $LND.LogicalNetwork.Name -SubnetVLan $LND.SubnetVLans -Name $LND.Name -VMHostGroup $LND.HostGroups

         # //Read IP pools on this LN and create accordingly
        $IPPools = Get-SCStaticIPAddressPool -VMMServer $VMMToRead -LogicalNetworkDefinition $LND
        ForEach ($IPPool in $IPPools) {
        Write-Verbose "Create IP Pool: $($IPPool.Name) on $($VMMServerToCreate)" 
        New-SCStaticIPAddressPool -VMMServer $VMMToCreate -LogicalNetworkDefinition $LNDToCreate -Name $IPPool.Name -Description $IPPool.Description -Subnet $IPPool.Subnet -Vlan $IPPool.VLanID -IPAddressRangeStart $IPPool.IPAddressRangeStart -IPAddressRangeEnd $IPPool.IPAddressRangeEnd -VIPAddressSet $IPPool.VIPAddressSet -DNSServer $IPPool.DNSServers -DNSSuffix $IPPool.DNSSuffix -NetworkRoute $IPPool.NetworkRoute -IPAddressReservedSet $IPPool.IPAddressReservedSet -WINSServer $IPPool.WINSServers -EnableNetBIOS $IPPool.EnableNetBIOS | Out-Null          
        }    
     }
     
     # //Read VM Network on this LN and create accordingly  
     $VMNetwork = Get-SCVMNetwork -VMMServer $VMMToRead -LogicalNetwork $ReadLogicalNetwork
     Write-Verbose "Create VM Network: $($VMNetwork.Name) on $($VMMServerToCreate)" 
     New-SCVMNetwork -VMMServer $VMMToCreate -Name $VMNetwork.Name -LogicalNetwork $LNToCreate -IsolationType $VMNetwork.IsolationType -Description $VMNetwork.Description | Out-Null                  

}

You can also use this script to merge two different VMM servers to make them use the same configuration.

Here is the output after you run the script.

SCVMM Logical Networks Migration
SCVMM Logical Networks Migration

You can verify that all networks are created successfully on the second VMM server:

SCVMM Logical Networks Verification
SCVMM Logical Networks Verification

Hopefully, this helps anyone else coming across this scenario.

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Previous

Using Volume Mount Points with Modern Backup Storage in DPM 2016 #DPM #MBS #SCDPM #MABS

Getting Started with Microsoft Project Honolulu #SeverMgmt #WS #S2D #HyperV #HCI @servermgmt

Next

4 thoughts on “How To Migrate Logical Networks from VMM to VMM with PowerShell #VMM #SCVMM #HyperV #PowerShell”

Leave a comment...

  1. Hi Charbel,

    How do we move the IP Pools from old VMM to new VMM. I am worried about IP conflict. Let me give you a scenario.

    We have defined following pool range
    172.20.20.10- 172.20.20.100. However, I am manually assigning the following IP 172.20.20.15 to a guest server. Does VMM will ignore this ip from the pool? or it will conflict. I don’t want put this IP in VMM pool exclusion. How does it work?

    Thanks in advance.

  2. Hello Sandeep,

    Yes, VMM will ignore this IP from the Pool as long as it detects that this IP (172.20.20.15) is used by one the guest VM.
    No worries, you can go ahead without making any exclusion.

    Thanks,
    -Charbel

  3. Hi Charbel,

    I have multiple VLANs on my physical network, which will be part of Hyper-V network as well.
    I have a confusion that do I have to create multiple logical network for each VLAN or a single logical network with network site for each VLAN.
    I have tried both options and both are working fine.
    Just want to confirm what is the industry best practice for Hyper-V environment.
    Thanks in advance,

    Deepak

  4. Hello Deepak, thank you for your question!

    In a Hyper-V environment with SCVMM, the best practice depends on the design and scalability of your network. Here’s a quick breakdown:

    Multiple Logical Networks for each VLAN: This approach gives you greater control and isolation at the logical level, which can be useful if you’re working with different tenant environments or want to apply specific policies or configurations for each VLAN separately. It’s ideal for environments with distinct network requirements or high complexity.

    Single Logical Network with Network Sites for each VLAN: This is a more scalable approach, especially in simpler environments. You define one logical network and then create network sites to handle the VLANs. This way, VMM will automatically associate the right VLAN with the right hosts based on their physical location (subnet). It’s a cleaner and more efficient way to manage networks, especially when dealing with many VLANs in a relatively homogeneous environment.

    Now, most organizations that I have seen in the field tend to use a single logical network with multiple network sites. It simplifies the management and is usually recommended when you have a consistent network configuration across your hosts. However, if you need strong isolation or specialized configurations, multiple logical networks might be necessary.

    I hope this clarifies things!

Let us know what you think, or ask a question...