cannot use script to vmotion vms

I trid to use the following script to migrate vms. but it complains about the object names. Could anyone help to take a look>?

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> gc .\vms.txt| Where-Object { $_.Trim() } | %{Get-VM -Name $_ | Move-VM -Destination -
Move-VM : 6/25/2015 8:55:15 PM    Move-VM        Could not find VIContainer with name ''.
At line:1 char:64
+ gc .\vms.txt| Where-Object { $_.Trim() } | %{Get-VM -Name $_ | Move-VM -Destinat ...
+                                                                ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ( [Move-VM], VimException
    + FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_ObjectNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

Move-VM : 6/25/2015 8:55:15 PM    Move-VM        VIContainer parameter: Could not find any of the objects specified by name.
At line:1 char:64
+ gc .\vms.txt| Where-Object { $_.Trim() } | %{Get-VM -Name $_ | Move-VM -Destinat ...
+                                                                ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (VMware.VimAutom...ner Destination:RuntimePropertyInfo) [Move-VM], ObnRecordProcessingFailedException
    + FullyQualifiedErrorId : Core_ObnSelector_SetNewParameterValue_ObjectNotFoundCritical,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI>
Jason YuAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Zephyr ICTCloud ArchitectCommented:
Does it work if you replace your VMHost name with its IP-address? Like so:

gc .\vms.txt| Where-Object { $_.Trim() } | %{Get-VM -Name $_ | Move-VM -Destination (Get-VMHost

Open in new window

Replace with the IP-address of your VMHost.

If that works there could be issues with the host DNS name not resolving correctly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
How did you format the vm.txt file? Each host on a separate line separated by semicolons...

I would assume a manually vmotion works just fine correct?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.