Hello,
I am trying to build a powercli script to vmotion/svmotion bulk of VMs at the same to other cluster using a CSV.
I found something but it will start first VM and wait to complete then start the second. my request is simultaneous move.
Any help it will be appreciated,
Firstly, you've posted in the wrong sub-forum (you want PowerCLI). Secondly, depending on how many you have to move, a parallel vMotion of many VMs may not be possible because of the limitations ESXi places on such operations. I believe the default is 8 concurrent vMotions per host.
vCenter calculates the available nic/bandwitdh on both source and target hosts and limited the number parallel vMotion tasks based on these numbers. Have someone ever setup a multi-nic vmotion with 3 or more nics?
Regards,
Joerg
Hello,
I will be ok with 8 concurrent vMotions per host.
And because it is related to vsphere i posted here.
Thx.
Hello Hassan,
Good thing is MOve-Vm cmdlet allows -RunAsync parameter which is basically excute this task parallely. Move-VM
You can use do while loop until you hit max number of task defined by you.
Just see if you can do it by yourself or i will have a sample code for you to play with
Hello,
First of all thanks a lot,
I prefer if you share a sample please.
Yes, but you're asking for PowerCLI code, right? If so, it's best put in PowerCLI.
Hi,
Try to use below powercli.
Just replace the Item in bold with the VM name, Cluster name and Datastore name.
Move-VM -VM VM_Name -Destination Destination_Cluster_Name -Datastore Destination_Datastore_Name -Confirm:$false
Appreciated,
But noting that this script will move one VM.
My case is i have a CSV file contains a list of VMs and destination host of each one.
I wanna prepare a script to move them simultaneous.
Please advise,
Hello Hasan,
Please try below Script. Caution ! I didn't had a chance to test but seems like it will work.
1. Create a vm-move.csv CSV file with only 2 cloumn, VMName and EsxHostName. Based on your query it seems like you have vmname and destination host where it needs to be moved so in that case this csv will work out best.
2. Save below script and run it against your intended VC where VMs are located. Ensure to update below csv file.
#Script_Start
$inputfile= Import-csv C:\users\jatin.purohit\vm-move.csv
foreach($vm in $inputfile.VMName)
{
Get-VM $inputfile.VMName |Move-VM -Destination $inputfile.EsxHostName -Runasync -Verbose
}
#Script_End
Do let me know if it is helpful or serve your purpose. If number of VMs are less then no issue if you have large number of VMs then we can limit the concurrent jobs to any number you want. Cheers!
Small modification below script might not take ESXI object in Move-VM cmdlet.. Please use below one.
Connect-VIServer -VIServer "your vc Name"
$inputfile= Import-csv C:\users\jatin.purohit\vm-move.csv
foreach($vm in $inputfile.VMName)
{
$esxiHost= Get-VMhost $inputfile.EsxHostName
Get-VM $inputfile.VMName |Move-VM -Destination $esxiHost -Runasync -Verbose
}
Now Earlier script will not give you any control on how many number of vMotion will work simultanously. As i said earlier, If you want to limit Number of vMotion to any number (You would prefer to do this in case you have more number of VMs and doesn't want to overload vMotion traffic).
Please use something like this. $NumberOfConJob= 2 Change the Value which suits you. In this case it will do 2 vMotion Jobs at a time. change this variable to any desired number which is suitable to you.
$inputfile= Import-csv C:\users\jatin.purohit\vm-move.csv
foreach($vm in $inputfile.VMName)
{
$NumberOfConJob= 2
$a=1
do{
$a
$a++
$esxiHost= Get-VMhost $inputfile.EsxHostName
Get-VM $inputfile.VMName |Move-VM -Destination $esxiHost -Runasync -Verbose
}
While ($a -le $NumberOfConJob)
}
Will update you as soon as we will apply it.
Thanks, Appreciated !!