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

| , ,

Published on | Updated on July 30, 2020

3 Min. Read

Contents of this Article

Introduction

VMM permits us to create 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 in VMM was always pain to deal with.

Scenario

After working with an implementation of 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 look like this:

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

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:
Cover Page
.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.

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

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

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

Hopefully this helps anyone else coming across this scenario.

Cheers,
[email protected]

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

2 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.

    Reply
    • 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

      Reply

Leave a comment below...

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to Charbel Nemnom’s Blog

Get the latest posts delivered right to your inbox

The content of this website is copyrighted from being plagiarized! However, you can copy from the 'Code Blocks'.

Please send your feedback to the author using this form for any 'Code' you like.

Thank you for visiting!