When I submit: Move-VM -VM $VMname.Name -Destination $destination.name -Datastore $destinationDatastore
The error occurs: Error: Move-VM Could not find Machine with name 'xxxx'
Get-VM -Name $VMName gets the name correctly. So,what could be the problem and how to solve it?
If found GitHub - skant11/PSxVCvMotion and this works for me.
Why do you use $VMname.Name?
What exactly do you have in $VMName?
Does any of the following work?
Move-VM -VM $VMname -Destination $destination.name -Datastore $destinationDatastore
Move-VM -VM (Get-VM -Name $VMname.Name) -Destination $destination.name -Datastore $destinationDatastore
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$destination.name = FQDN of the host
Move-VM -VM $VMname -Destination $destination.name -Datastore $destinationDatastore
Move-VM : 19-8-2022 12:38:42 Move-VM Could not find VIContainer with name 'DESTINATIONHOST'
Get-VMHost -Name DESTINATIONHOST-FQDN gives correct result
BTW:
PowerCLI Version
----------------
VMware PowerCLI 10.1.0 build 8346946
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component PowerCLI Component 10.1 build 8377811
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 10.1 build 8344055
PowerCLI Version
----------------
VMware PowerCLI 10.1.0 build 8346946
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component PowerCLI Component 10.1 build 8377811
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 10.1 build 8344055
PowerCLI Version
----------------
VMware PowerCLI 10.1.0 build 8346946
---------------
Component Versions
---------------
VMware Cis Core PowerCLI Component PowerCLI Component 10.1 build 8377811
VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 10.1 build 83440
My question was about $VMName.Name
Perhaps it could be useful if you also showed how you populate all these variables that you use.
Also, instead of $destination.Name why don't you use just $destination?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Even if I don't use variables but use the hardcoded names it fails.
Move-VM -VM VMname -Destination FQDN-dest
Move-VM : 19-8-2022 15:19:30 Move-VM Could not find VirtualMachine with name 'VMname '.
Or this: Get-VM -Name VMname | Move-VM -Destination FQDN-dest
Move-VM : 19-8-2022 15:21:25 Move-VM Could not find VIContainer with name 'FQDN-dest'.
If I move the machine to another host in the same cluster it works.
If found GitHub - skant11/PSxVCvMotion and this works for me.