VMware Cloud Community
IKirill
Enthusiast
Enthusiast

PowerCli - Move disks to original DS

Hi!

I have multiple VMs with different number of disks and different datastores.
Now i wont use storage vmotion to move all disk to one datastore.
Then i use move-harddisk to move every HD with Storage Format EagerZeroedThick.
At the same time, the hard drives are moved to their original datastores.

How can I call each element of the array in a loop?

 

$vmhddsorigs = Get-VM mytest | Get-HardDisk

Move-VM -VM mytest -Datastore mydatastore1 -RunAsync

foreach ($vmhddsorigs in $vmhddsorig) {

$disknname=$_.diskname
$diskds=$_.datastore.name

get-vm mytest | Move-HardDisk -HardDisk $disknname -Datastore $diskds -StorageFormat EagerZeroedThick
}

 

0 Kudos
1 Reply
LucD
Leadership
Leadership

A Move-VM with the Datastore parameter is a svMotion afaik.


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

0 Kudos