I have a csv file like this
VM
| SRC_Cluster | DST_CLUSTER
| Group
|
---|
vm1 | clus1 | clus2 | 1 |
vm2 | clus1 | clus2 | 1 |
vm3 | clus1 | clus2 | 2 |
vm4 | clus1 | clus2 | 2 |
vm5 | clus1 | clus2 | 3 |
vm6 | clus1 | clus2 | 3 |
I want to shutdown Group 1 guests, move them from clus1 to clus2. power them on the new cluster. Wait until they are all powered on then move on to the next group.
mport-csv "c:\scripts\vms.csv" -useculture | %{
$vm = $_.VM
$src_cluster = $_.SRC_Cluster
$dst_Cluster = $_.DST_Cluster
$group = $_.group
write-host "shutting down prod-vm $vm"
$vm | stop-vmguest -confirm:$false
while($vm.PowerState -ne 'PoweredOff'){
$vm = Get-VM -Name $vm.Name
sleep 5
move-vm $vm -location $dst_cluster
start-vm $vm -confirm:$false
}
}
how do I pause from group to group?