Can some one provide me a Powercli script to migrate VMs across clusters. The script should shutdown the VM and migrate the VMs to specified Datastore and cluster.
Hello,
this should do the trick!
(The vms you want to migrate, must have installed (and running) the vmware tools)
Get-Content "C:\vms.txt" | %{
Get-VM -Name $_ | Shutdown-VMGuest -Confirm:$false
}
# Wait some time to be sure all the vms are powered off (120 seconds for exemple)
Start-Sleep -s 120
Get-Content "C:\vms.txt" | %{
Move-VM $_ -Datastore myDestDatastore -Destination (Get-Cluster myDestCluster | Get-VMHost | ?{$_.State -eq "Connected"} | Get-Random) -RunAsync
}
Best regards,
Pablo
Well If we would like to move VMs to Hosts based on Host resource utilisation in the cluster, how can we get it done.