VMware Cloud Community
alinar
Contributor
Contributor

Moving hosts between datacenters with PowerCLI

Hi,  I am trying to move ESXi from one vCenter to other via PowerCLI , using command:

Move-VMHost -VMHost ESXimachine -Destination host2

have the error:

Could not find VIContainer with name 'host2'.

(The ESXimachine is in maintenance mode.)

I am using:

PowerCLI version 5.1 release 1

VNware vCenter Server 5.5.0, 1750787

Any solutions?

Thanks

Alina

0 Kudos
8 Replies
LucD
Leadership
Leadership

Is host2 the name of a datacenter ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
alinar
Contributor
Contributor

No it is the name of a destination vCenter

0 Kudos
LucD
Leadership
Leadership

Can you try using a datacenter or folder on the target vCenter ?

But I'm not sure that will work.

Why don't you try a Remove-Host on the old vCenter, and then an Add-VMHost on the new vCenter ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
alinar
Contributor
Contributor

Hi , thanks for your replay ,

Good idea,

Removing was successful , but - have the same error while trying to add the server to new vCenter.

the command:

Add-VMHost -Name ESXimachine -Location host2 -User alinar -Password ****

0 Kudos
snoopj
Enthusiast
Enthusiast

Looking at the Add-VMHost cmdlet, I don't believe you can just pass a vCenter name in the -Location argument.  That argument is looking for some sort of object in the vCenter to add itself to (like a cluster/resource pool/folder/etc).  I think the assumption should be that you've already connected to your vCenter before hand with a Connect-VIServer.

For instance, this is an example that I used to migrate VMs when we outgrew a large vCenter and split vCenter instances around:

Connect-VIServer $newvCenter

# Create new cluster

$cluster = New-Cluster -Location $newvCenterDatacenter -Name $origClusterName

# Add hosts to new vCenter

foreach ($vmhost in $vmhosts) { Add-VMHost -Name $vmhost.Name -Location $cluster -User root -Password <!!!!!!> -Force -Confirm:$false }

This was the immediate PowerCLI lines after disconnecting from the first vCenter.  I create a new cluster in a datacenter with the old cluster name.  I then take my array of hosts and add them to that cluster.

0 Kudos
LucD
Leadership
Leadership

The Location parameter needs to have a VIContainer object, that can't be a vCenter.

Use a datacenter or a folder


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
esxi1979
Expert
Expert

This thread needs to be moved to correct location .. Please do needful

0 Kudos
LucD
Leadership
Leadership

Thread moved to VMware vSphere™ PowerCLI


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos