How would you script migrating all VMDK's from one datastore to another datastore.
No, then you would have to use the Move-VM cmdlet. But that cmdlet will move all files to the destination datastore.
The alternative is to use the RelocateVM_Task method, that allows more flexibility to define what goes where.
There is a good example in your thread called Using multiple datastores, can't migrate the vmx file to a datastore
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Something like:
Get-Datastore "OldDatastore" | Get-VM | Get-HardDisk | Where_Object {$_.FileName -like "*OldDatastore*"} | Set-HardDisk -Datastore "NewDatastore"
Regards, Robert
Robert,
Will this also move vmx files if they are in the datastore?
No, then you would have to use the Move-VM cmdlet. But that cmdlet will move all files to the destination datastore.
The alternative is to use the RelocateVM_Task method, that allows more flexibility to define what goes where.
There is a good example in your thread called Using multiple datastores, can't migrate the vmx file to a datastore
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Oh yeah, I forgot about that one. Thanks