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.
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.
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
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.
And that is always Hard Disk 2?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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.
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
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.