0

I have tried and search multiple way to migrate VM's to different data store

$existingds = Get-Content dummy path

$newds = Get-Content dummypath

Get-Datastore $existingds | Get-VM | Move-VM -DiskStorageFormat Thick -Datastore $newds –RunAsync

But for some reason, it is not working, I'm getting this error: Move-VM : Cannot convert 'System.Object[]' to the type 'VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.StorageResource' required by parameter 'Datastore'. Specified method is not supported.

If I run the command move-vm -vm vmname -datastore new datastore, it works without issue but when I try to put into an array, it throws an error.

Davidw
  • 1,210
  • 3
  • 14
  • 24
Mohit
  • 1

1 Answers1

2

-Datastore requires a datastore object, but you are providing an array of strings.

This should work:

Get-Datastore $existingds | Get-VM | Move-VM -DiskStorageFormat Thick -Datastore (Get-Datastore $newds) –RunAsync
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79