Using Powershell to Migrate SCVMM VM Network and IP Pools

%3CLINGO-SUB%20id%3D%22lingo-sub-1579079%22%20slang%3D%22en-US%22%3EUsing%20Powershell%20to%20Migrate%20SCVMM%20VM%20Network%20and%20IP%20Pools%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1579079%22%20slang%3D%22en-US%22%3E%3CP%3EI%E2%80%99m%20trying%20to%20migrate%20in%20VMM%202016%20the%20VM%20Network%2C%20VM%20Logical%20Network%2C%20and%20all%20IP%20Pools%20that%20go%20with%20that%20network.%20See%20in%20the%20attached%20code%20block%20the%20first%20two%20sections%20do%20work%20OK.%20It%20finds%20and%20creates%20the%20logical%20network%20and%20the%20VM%20network%20from%20the%20source%20VMM%20server.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20run%20the%203rd%20section%20to%20read%20and%20create%20the%20Logical%20Network%20Definitions%20I%20get%20the%20error%3A%3C%2FP%3E%3CP%3ENew-SCLogicalNetworkDefinition%20%3A%20Unable%20to%20find%20the%20specified%20host%20group.%20The%20host%20group%20name%20may%20be%20incorrect%2C%20or%20the%20host%20group%20may%20have%20been%20moved%20or%20deleted.%20(Error%20ID%3A%201750)Verify%20that%20the%20host%20group%20name%20is%20correct%2C%20that%20the%20host%20group%20exists%20on%20the%20Virtual%20Machine%20Manager%20management%20server%2C%20and%20that%20the%20host%20group%20is%20in%20the%20specified%20host%20path.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20its%20something%20with%20that%20-VMHostGroup%20%24LND.HostGroups%20section.%20However%20if%20I%20run%20just%20the%20variable%20%24LND.HostGroups%20it%20returns%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EPS%20C%3A%5CWindows%5Csystem32%26gt%3B%20%24LND.HostGroups%0A%0AAllowUnencryptedTransfers%20%3A%20True%0ACreationDate%20%3A%206%2F4%2F2013%204%3A34%3A35%20PM%0ACreator%20%3A%20ME%5Cuser%0ADescription%20%3A%0AID%20%3A%2017441540-f13f-438f-ac3c-81994f2d440e%0AInheritNetworkSettings%20%3A%20True%0AIsFullyCached%20%3A%20True%0AIsRoot%20%3A%20False%0AMarkedForDeletion%20%3A%20False%0AModificationDate%20%3A%207%2F17%2F2017%209%3A23%3A13%20AM%0AModifiedBy%20%3A%20ME%5Cuser%0AName%20%3A%20Group%201%20Hosts%0AParentHostGroup%20%3A%20All%20Hosts%0APath%20%3A%20All%20Hosts%5CGroup%201%20Hosts%0AServerConnection%20%3A%20Microsoft.SystemCenter.VirtualMachineManager.Remoting.ServerConnection%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20suggestions%20on%20how%20to%20get%20around%20this%3F%20This%20Logical%20network%20has%20about%20100%20IP%20Pools%20under%20it%20I%20would%20like%20to%20not%20have%20to%20manually%20re-enter%20on%20the%20new%20VMM%20server%20I%20am%20working%20on.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23%20Find%20logical%20network%20being%20queried%20from%20SourceVMMsvr%20and%20Create%20it%20on%20DestVMMsvr%0A%20%24ReadLogicalNetwork%20%3D%20Get-SCLogicalNetwork%20-VMMServer%20SourceVMMsvr%20%7C%20Where-Object%20Name%20-eq%20%E2%80%9CVM%20Logical%20Network%201%E2%80%9D%0A%20New-SCLogicalNetwork%20%24ReadLogicalNetwork%20-VMMServer%20DestVMMsvr%0A%20%20%20%20%0A%20%23%20Read%20VM%20Network%20on%20SourceVMMsvr%20and%20create%20on%20DestVMMsvr%0A%20%24VMNetwork%20%3D%20Get-SCVMNetwork%20-VMMServer%20SourceVMMsvr%20-LogicalNetwork%20%24ReadLogicalNetwork%0A%20New-SCVMNetwork%20-VMMServer%20DestVMMsvr%20-Name%20%24VMNetwork.Name%20-LogicalNetwork%20%24LNToCreate%20-IsolationType%20%24VMNetwork.IsolationType%20-Description%20%24VMNetwork.Description%20%7C%20Out-Null%0A%20%20%20%20%0A%20%23%20Read%20the%20Logical%20Network%20Definitions%20from%20SourceVMMsvr%20and%20create%20on%20DestVMMsvr%0A%20%24LNDs%20%3D%20Get-SCLogicalNetworkDefinition%20-LogicalNetwork%20%24ReadLogicalNetwork%20-VMMServer%20SourceVMMsvr%0A%20ForEach%20(%24LND%20in%20%24LNDs)%20%7B%0A%20%24LNDToCreate%20%3D%20New-SCLogicalNetworkDefinition%20-VMMServer%20DestVMMsvr%20-LogicalNetwork%20%24LND.LogicalNetwork.Name%20-SubnetVLan%20%24LND.SubnetVLans%20-Name%20%24LND.Name%20-VMHostGroup%20%24LND.HostGroups%0A%20%20%20%20%0A%20%23%20Read%20IP%20pools%20on%20this%20Logical%20Network%20and%20create%20on%20DestVMMsvr%0A%20%24IPPools%20%3D%20Get-SCStaticIPAddressPool%20-VMMServer%20SourceVMMsvr%20-LogicalNetworkDefinition%20%24LND%0A%20ForEach%20(%24IPPool%20in%20%24IPPools)%20%7B%0A%20New-SCStaticIPAddressPool%20-VMMServer%20DestVMMsvr%20-LogicalNetworkDefinition%20%24LNDToCreate%20-Name%20%24IPPool.Name%20-Description%20%24IPPool.Description%20-Subnet%20%24IPPool.Subnet%20-Vlan%20%24IPPool.VLanID%20-IPAddressRangeStart%20%24IPPool.IPAddressRangeStart%20-IPAddressRangeEnd%20%24IPPool.IPAddressRangeEnd%20-VIPAddressSet%20%24IPPool.VIPAddressSet%20-DNSServer%20%24IPPool.DNSServers%20-DNSSuffix%20%24IPPool.DNSSuffix%20-NetworkRoute%20%24IPPool.NetworkRoute%20-IPAddressReservedSet%20%24IPPool.IPAddressReservedSet%20-WINSServer%20%24IPPool.WINSServers%20-EnableNetBIOS%20%24IPPool.EnableNetBIOS%20%7C%20Out-Null%0A%20%7D%0A%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1579079%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESystem%20Center%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Visitor

I’m trying to migrate in VMM 2016 the VM Network, VM Logical Network, and all IP Pools that go with that network. See in the attached code block the first two sections do work OK. It finds and creates the logical network and the VM network from the source VMM server.

 

When I run the 3rd section to read and create the Logical Network Definitions I get the error:

New-SCLogicalNetworkDefinition : Unable to find the specified host group. The host group name may be incorrect, or the host group may have been moved or deleted. (Error ID: 1750)Verify that the host group name is correct, that the host group exists on the Virtual Machine Manager management server, and that the host group is in the specified host path.

 

So its something with that -VMHostGroup $LND.HostGroups section. However if I run just the variable $LND.HostGroups it returns:

 

 

PS C:\Windows\system32> $LND.HostGroups

AllowUnencryptedTransfers : True
CreationDate : 6/4/2013 4:34:35 PM
Creator : ME\user
Description :
ID : 17441540-f13f-438f-ac3c-81994f2d440e
InheritNetworkSettings : True
IsFullyCached : True
IsRoot : False
MarkedForDeletion : False
ModificationDate : 7/17/2017 9:23:13 AM
ModifiedBy : ME\user
Name : Group 1 Hosts
ParentHostGroup : All Hosts
Path : All Hosts\Group 1 Hosts
ServerConnection : Microsoft.SystemCenter.VirtualMachineManager.Remoting.ServerConnection

 

 

Any suggestions on how to get around this? This Logical network has about 100 IP Pools under it I would like to not have to manually re-enter on the new VMM server I am working on.

 

 

# Find logical network being queried from SourceVMMsvr and Create it on DestVMMsvr
 $ReadLogicalNetwork = Get-SCLogicalNetwork -VMMServer SourceVMMsvr | Where-Object Name -eq “VM Logical Network 1”
 New-SCLogicalNetwork $ReadLogicalNetwork -VMMServer DestVMMsvr
    
 # Read VM Network on SourceVMMsvr and create on DestVMMsvr
 $VMNetwork = Get-SCVMNetwork -VMMServer SourceVMMsvr -LogicalNetwork $ReadLogicalNetwork
 New-SCVMNetwork -VMMServer DestVMMsvr -Name $VMNetwork.Name -LogicalNetwork $LNToCreate -IsolationType $VMNetwork.IsolationType -Description $VMNetwork.Description | Out-Null
    
 # Read the Logical Network Definitions from SourceVMMsvr and create on DestVMMsvr
 $LNDs = Get-SCLogicalNetworkDefinition -LogicalNetwork $ReadLogicalNetwork -VMMServer SourceVMMsvr
 ForEach ($LND in $LNDs) {
 $LNDToCreate = New-SCLogicalNetworkDefinition -VMMServer DestVMMsvr -LogicalNetwork $LND.LogicalNetwork.Name -SubnetVLan $LND.SubnetVLans -Name $LND.Name -VMHostGroup $LND.HostGroups
    
 # Read IP pools on this Logical Network and create on DestVMMsvr
 $IPPools = Get-SCStaticIPAddressPool -VMMServer SourceVMMsvr -LogicalNetworkDefinition $LND
 ForEach ($IPPool in $IPPools) {
 New-SCStaticIPAddressPool -VMMServer DestVMMsvr -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
 }
 }

 

 

 

0 Replies