Hi All Experts :),
I did use the below code for migrating the VM from one host to another and its working fine. But I am looking to migrate some multiple VMs and want the script to read the VM name and Host name from a CSV file or path. Please could you let me know what code I have to use in this below script.
$vms = Get-VM -Name VM-Name
$desthost = Get-VMHost -Name "esxhost.local"
foreach ($singlevm in $vms) {
Shutdown-VMGuest -VM $singlevm -Confirm:$false
while ((Get-VM $singlevm).PowerState -ne "PoweredOff") { Start-Sleep -Seconds 5 }
Move-VM -vm $singlevm -Destination $desthost
Start-VM -VM $singlevm
}
Moderator edit by wila: Moved to PowerCLI discussions