VMware Cloud Community
JSJ6
Contributor
Contributor
Jump to solution

Moving multiple independent disks via PowerCLI

I have a situation where I want to move multiple independent disks (Hard disk 1, hard disk 3, hard disk 4) to another datastore due to a storage array being replaced.  I am aware of how to do it for ONE single disk, but I am unsure how to automate this for multiple disks.  I simply want to take 3 independent disks and move them to a datastore cluster through PowerCLI.

I could simply do this using the advanced feature in storage vmotion but I would rather develop a simple script because I will need to then move the data BACK to the new storage appliance once we procure it.

I appreciate any suggestions.

1 Solution

Accepted Solutions
JSJ6
Contributor
Contributor
Jump to solution

Thats a handy CLI command, Luc.  I will have to remember that.

Since the VMs are all linked clones, I was able to simply change the OS dependent disk location and the disposable disk location in the pool settings so that all new VMs are created on the new datastores.  When I recompose the pool, it recreated the VMs on the datastore I selected in the pool and now all of my VMs are able to keep their persistent disk locations (since I did not want to move them, just the OS dependent disk and disposable disk) while changing the OS and disposable locations.

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this.

Note that if you have SDRS fully automated and VMDK affinity, the harddisk might be moved back.

Get-VM | Get-HardDisk | where{$_.Persistence -match "^Independent"} |

Move-HardDisk -Datastore DSC


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JSJ6
Contributor
Contributor
Jump to solution

I apologize, I should have mentioned that I want to OMIT moving the view composer persistent independent disk (Hard disk 2) from the bunch.  So in essence, I would be moving a dependent and two independent disks.  I apologize for not clarifying that previously.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

And that is always Hard Disk 2?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JSJ6
Contributor
Contributor
Jump to solution

After second look, it appears the features that are shared is that the disk I want to omit is 20.000 gb across the board and is an independent disk.  These two qualities are shared for EVERY view composer persistent disk.  So it looks like I want to move all disks EXCEPT that 20.000 GB independent disk.

Each VM looks like this:

-OS dependent disk

-4GB disposable disk

- 20GB view composer persistent disk

I want to migrate the dependent disk and 4Gb disposable disk to another datastore and omit the migration of the view composer disk, if that makes sense.  VDI is not yet my specialty, so excuse me for that.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could try like this

Get-VM | Get-HardDisk | where{$_.CapacityGB -ne 20GB} |

Move-HardDisk -Datastore DSC


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

JSJ6
Contributor
Contributor
Jump to solution

Thats a handy CLI command, Luc.  I will have to remember that.

Since the VMs are all linked clones, I was able to simply change the OS dependent disk location and the disposable disk location in the pool settings so that all new VMs are created on the new datastores.  When I recompose the pool, it recreated the VMs on the datastore I selected in the pool and now all of my VMs are able to keep their persistent disk locations (since I did not want to move them, just the OS dependent disk and disposable disk) while changing the OS and disposable locations.

Reply
0 Kudos