Score:1

move-vm not working : Could not find VirtualMachine with name

in flag

I am trying to cross migrate VM across two Vcenters ( from 6.5 to 7.0) with move-vm command, but something is wrong, couldn't find my test-vm, even basic get-vm find it.

$global:DefaultVIServers

Name                           Port  User
----                           ----  ----
host1.. 443   x.LOCAL\Admini...
host2.. 443   y.LOCAL\Admini...

$destination = 'new-host'
get-vm test-vm

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
test-vm              PoweredOff 2        4.000


Move-VM -VM test-vm -Destination $destination
Move-VM : 10/12/2022 7:16:06 AM Move-VM         Could not find VirtualMachine with name 'test-vm'.
At line:1 char:1
+ Move-VM -VM test-vm -Destination $destination
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (test-vm:String) [Move-VM], VimException
    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

Move-VM : 10/12/2022 7:16:06 AM Move-VM         Value cannot be found for the mandatory parameter VM
At line:1 char:1
+ Move-VM -VM test-vm -Destination $destination
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Move-VM], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

trying with -Server option: not works, looks that I can use this option only once in whole command

 Move-VM -VM test-vm -server 'host1'  -Destination $destination -Server 'host2'
Move-VM : Cannot bind parameter because parameter 'Server' is specified more than once. To provide multiple values to parameters that can accept multiple values, use the array syntax. For example, "-parameter value1,value2,value3".
At line:1 char:98
in flag
Are the two vcenters linked?
andrew avatar
in flag
not sure what you mean linked, but I am connected to both, only issue is that datacenter name and cluster name is equal on both, but probably not the block here. Both VC have access to datastores and vlans created on both. SO basically I am looking for register VM on new VC/cluster, I think this vm-move can do this also right ?
in flag
So, the VM is currently on an ESXi host managed by vCenter A and the target host is managed by vCenter B?
andrew avatar
in flag
yes, this way is it
in flag
Can you please edit the output of `$global:DefaultVIServers` into the question?
andrew avatar
in flag
added, so you think that VM is not find due to version differ ?
in flag
No, I think you need to specify the servers with the PowerCLI commands (`get-vm -server host1`, `get-vmhost -server host2`). But even then it will most probably not work because the requirements are not met.
andrew avatar
in flag
hmm, looks that I can use this -Server option only once in whole command
Score:1
tv flag

If you want to move your VM from vCenter A to vCenter B use VMware Converter Tool.
You can move the VM turn on without problems. Also there is a beta program maybe you can try the new tool. Take care about VM Guest OS because some OS are deprecated on vSphere 7.

Score:0
in flag

As there is shared the same Datastore on both Vcenters, Therefore for me works best this solution :

  1. save VMs vmx path files e.g. Get-VM | Select Name, @{N="VM Config File";E={$_.extensiondata.config.files.vmpathname}}

  2. unregister VMs on Vc1

  3. register VMs on Vc2: New-VM -VMFilePath '<PATH>' -ResourcePool 'Cluster'

Score:0
in flag

In your current configuration the migration is not possible.

Requirements for VMware VM migration to another vCenter

  • The source and target vCenter Server instances and ESXi hosts must be running version 6.0 or later.
    yes
  • The source vCenter and target vCenter should be on the same version.
    no
  • An Enterprise Plus license is required for cross-vCenter Server and long distance vMotion functionality.
    unknown
  • When using the vSphere Web Client, both vCenter Server instances must be in Enhanced Linked Mode and must be in the same vCenter single sign-on (SSO) domain so that the source vCenter Server can authenticate to the target vCenter Server.
    no

As you see, in the current configuration a simple direct migration is not possible. If your have an Enterprise Plus license you can update your 6.5 vCenter and link it to the other vCenter, then the migration should work.

Otherwise you can either migrate it manually (turn VM off, remove from vCenter, move files to new datastore if necessary, register VM, turn VM on) or you can use the VMware converter to do the conversion (VM must be off for this as well).

Score:0
tr flag

For the move-vm cmdlet the -VM parameter must be a VM object, not just the name of a VM. So it should work like this:

$vm = get-vm test-vm
Move-VM -VM $vm -Destination $destination

Have a look at the online help of move-vm for other examples like using pipelines etc:

get-help move-vm -examples
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.