VMware Cloud Community
MCioe
Enthusiast
Enthusiast
Jump to solution

Move-VM error: VM must be managed by same VI Servers as destination datastore

I am working with 2 ESXi servers and a single vCenter server with vSphere 6.0 update 1b; and PowerCLI 6.0 Release 2

I have a one datacenter, cluster, vCenter and one vDS.  I need to move the vCenter datastore to a different one and am getting the error:

"Move-VM  The VM that you move must be managed by the same VI Server as the destination container and datastore"

Code looks like the following:

$vctObj = connect-viserver $vctIPaddress

$esx1Obj = connect-viserver $esx1IPaddress

$esx2Obj = connect-viserver $esx2IPaddress

$vmObj = get-vm -name $vmname  -Server $vctObj

$destDSobj = get-datastore -name $destDSname

move-vm -vm $vmObj -Datastore $destDSobj -DiskStorageFormat "Thin"

I can successfully migrate the VM's datastore from vCenter via the VI Client, but PowerCLI has me stumped.

Maureen

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try using the Server parameter on the Get-Datastore line


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

View solution in original post

9 Replies
Devrawat2708
Contributor
Contributor
Jump to solution

Hi,

No need to connect to ESXi hosts as you are already connected to Vcenter.

Disconnect yourself from ESXi hosts.

Disconnect-viserver $esx1IPaddress

Disconnect-viserver $esx2IPaddress


Try again..

Reply
0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution

I disconnected from the the servers, but it didn't change the error.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try using the Server parameter on the Get-Datastore line


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

MCioe
Enthusiast
Enthusiast
Jump to solution

Luc, thank you SOO much, I tried so many variations, all I had to do was add a -server option on the Get-Datastore cmdlet.

$vctObj = connect-viserver $vctIPaddress

$esx1Obj = connect-viserver $esx1IPaddress

$esx2Obj = connect-viserver $esx2IPaddress

$vmObj = get-vm -name $vmname  -Server $vctObj

$destDSobj = get-datastore -name $destDSname -Server $vctObj

move-vm -vm $vmObj -Datastore $destDSobj -DiskStorageFormat "Thin"

Reply
0 Kudos
Sathish1121
Contributor
Contributor
Jump to solution

Hi LucD,

I am trying to perform the same operation, but using vCenter 6.x planning to migrate VM (compute only) from source vcenter to destination vcenter. I verified powercli config to be multiple and connected to multiple vcenter, but getting the below error message, does powercli recognizes the vsphere 6.xs enhanced vmotion? I verified this functionality in vSphere client and it is successfully, not able to figure it out in Powercli. getting the same error "The VM that you move must be managed by the same VI Server as the destination container and datastore"

Script

$sourcecluster = Get-Cluster "mysourcecluster" -Server mysourcevc

$destcluster = Get-Cluster "mydestcluster" -Server mydestvc

$vm = Get-VM myvm -Server mysourcevc

Move-VM -Destination $destcluster -VM $vm

i am attempting just compute vmotion, storage is shared

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Are the two vCenters in different SSO domains ?

If yes, William did a post on that, see Did you know of an additional cool vMotion capability in vSphere 6.0?


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

Reply
0 Kudos
Sathish1121
Contributor
Contributor
Jump to solution

Infact they are not in two SSO domain, hence I opted for the relatively simpler powercli script. I did see William's post, was exploring other straight forward scripts. Thanks for getting back.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you also try with the Server parameter (source vCenter) on the Move-VM cmdlet ?


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

Reply
0 Kudos
Sathish1121
Contributor
Contributor
Jump to solution

yep, same result.

Reply
0 Kudos