Is it possible to sepcify multiple vms from command line and vmotion them?
get-vm xxx | Move-VM -Destination (Get-VMHost esxi)
how can i do this from a script and csv file?
The script below seems to have some issues...
If you make a .csv file New-VMs.csv like the next example that has colomn headers in the first row:
VM,VMHost
VM1,ESX1
VM2,ESX2
You can move the virtual machines to the corresponding ESX servers with the following script:
param ( $CsvFile = "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\New-VMs.csv" ) Import-Csv -Path $CsvFile | ForEach-Object { $VMhost = Get-VMHost $_.VMHost Get-VM $_.VM | Move-VM -Destination $VMHost }
Regards, Robert
hi
this seems to work but does them one at a time. how do I vmotion all at the same time?
Just add -RunAsync to Move-VM:
param ( $CsvFile = "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\New-VMs.csv" ) Import-Csv -Path $CsvFile | ForEach-Object { $VMhost = Get-VMHost $_.VMHost Get-VM $_.VM | Move-VM -Destination $VMHost -RunAsync }
You do know that there is a limit on the number of simultanious vMotions ?
Check page 227 in the vSphere Datacenter Administration Guide
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference