VMware Cloud Community
E4F
Contributor
Contributor
Jump to solution

How to migrate all VMDK's from one datastore to another datastore

How would you script migrating all VMDK's from one datastore to another datastore.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
4 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

Something like:

Get-Datastore "OldDatastore" | Get-VM | Get-HardDisk | Where_Object {$_.FileName -like "*OldDatastore*"} | Set-HardDisk -Datastore "NewDatastore"

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
E4F
Contributor
Contributor
Jump to solution

Robert,

Will this also move vmx files if they are in the datastore?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
E4F
Contributor
Contributor
Jump to solution

Oh yeah, I forgot about that one.  Thanks

0 Kudos