I have a requirement to perform online migration of 100+ Powered-on VMs from one cluster to another without shared storage.
I know that we can do it through Web-Client, but is it possible using PowerCLI.
Can the below steps be done on powered-on VMs using PowerCLI script? Please help
Step 1: Select change both compute resource and storage
Step 2: Select the destination host/cluster
Step 3: Select the datastore
Step 4: Select the network
Yes, that should be possible.
Try like this
$esxName = 'TgtEsx'
$dsName = 'TgtDatastore'
$pgName = 'TgtPortgroup'
$vm = Get-VM -Name $vmName
$pg = Get-VirtualPortGroup -Name $pgName
Move-VM -VM $vm -Destination $esxName -Datastore $dsName -PortGroup $pg -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, that should be possible.
Try like this
$esxName = 'TgtEsx'
$dsName = 'TgtDatastore'
$pgName = 'TgtPortgroup'
$vm = Get-VM -Name $vmName
$pg = Get-VirtualPortGroup -Name $pgName
Move-VM -VM $vm -Destination $esxName -Datastore $dsName -PortGroup $pg -Confirm:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks for your response.
It is working fine for single VM.
But when i try run for multiple VMs i get an error.. Can you please help?
contents of "servers.csv"
name,host,datastore,portgroup
vm1,esx1,ds1,pg1
vm2,esx2,ds2,pg2
vm3,esx3,ds3,pg3
vm4,esx4,ds4,pg4
$vms = Import-CSV C:\Script\servers.csv
foreach ($vm in $vms){
$VMname = Get-VM -Name $vm.name
$VMhost = Get-VMHost $vm.host
$Datastore = Get-Datastore $vm.datastore
$PGname = Get-VirtualPortGroup -Name $vm.portgroup
Move-VM -VM $VMname -Destination $VMhost -Datastore $Datastore -PortGroup $PGname -Confirm:$false
}
That is a timeout (the default of 300 seconds or 5 minutes).
Could be caused by many factors.
Try increasing the timeout with the Set-PowerCLIConfiguration cmdlet and the WebOperationTimeoutSeconds parameter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
It worked. Thanks for your help.