question

RandyVitorivich-4587 avatar image
0 Votes"
RandyVitorivich-4587 asked RandyVitorivich-4587 commented

Migrating VM Network and IP Pools with Powershell in VMM

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

 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
 }
 }


msc-virtual-machine-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AndyLiu-MSFT avatar image
0 Votes"
AndyLiu-MSFT answered RandyVitorivich-4587 commented

Based on the cmdlet "$LND.HostGroups", the retrieved host group "Group 1 Hosts" resides on the source SCVMM server.

You must create a same host group on the destination SCVMM server, and get the host group from the destination SCVMM server, not the source one.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You must create a same host group on the destination SCVMM server, and get the host group from the destination SCVMM server, not the source one.

@AndyLiu-MSFT thank you for the reply. I'm confused over this statement however.

For "$LND.HostGroups", the retrieved host group "Group 1 Hosts" indeed does reside on the source SCVMM server. The powershell gets that information from this line:

$LNDs = Get-SCLogicalNetworkDefinition -LogicalNetwork $ReadLogicalNetwork -VMMServer SourceVMMsvr
ForEach ($LND in $LNDs) ........

The same host group was already there on the destination SCVMM, manually created on the destination SCVMM server before running the script in the original message.

What am I missing?





0 Votes 0 ·

I mean if you have already created host group on the destination SCVMM server, you should retrieve the host group object on the destination SCVMM server.

 $hg1 = Get-SCVMHostGroup -VMMServer DestVMMsvr | Where-Object Name -EQ "Group 1 Hosts"   
 New-SCLogicalNetworkDefinition -VMMServer DestVMMsvr -LogicalNetwork $LND.LogicalNetwork.Name -SubnetVLan $LND.SubnetVLans -Name $LND.Name -VMHostGroup $hg1

From the code example above, $LND.HostGroups has been replaced by $hg1.


0 Votes 0 ·

You've done it for me with that clarification, that was the missing need. I managed to get all the VM Network, Logical Network, and IP Pools imported to the right places.

0 Votes 0 ·