Table of Contents
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:
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.
You can verify that all networks are created successfully on the second VMM server:
Hopefully this helps anyone else coming across this scenario.
Cheers,
-Ch@rbel-
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.
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