when i run this, I think limit is only 10 svmotions at one time?
get-datastore -name (ds1) | get-vm | move-vm -datastore (get-datastore -name ds2) -runasync
how do I loops it so it continues after 10vms
The number of parallel svMotion is indeed limited, but the other ones should be queued and run in the end.
Do you see differently?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes it does. I wanted to ad a progress bar to it
What kind of progress bar?
One for each of the background tasks, or one for all the tasks?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
actually can i do something like this for multiple ds
Import-Csv "C:\scripts\dsmigration.csv" -UseCulture | % {
$old_ds = $_.old_ds
$new_ds = $_.new_ds
$VMs = get-vm -Datastore $old_ds
$VMs | move-vm -Datastore $new_ds -RunAsync
}
my csv file is
old_ds,new_ds
ds1,ds10
ds2,ds11
etc...
Yes, that should work
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
do i need a for loop for this to work on multiple ds? and can i add a progress bar per vm?
Your sample code has a loop after the Import-Csv.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes.
also trying to dismount all isos before proceeding
Import-Csv "C:\scripts\dsmigration.csv" -UseCulture | % {
$old_ds = $_.old_ds
$new_ds = $_.new_ds
$VMs = get-vm -Datastore $old_ds
# Check is any iso mounted on vms
foreach ($vm in $VMs) {
if ((Get-VM $vm | Get-CDDrive).isopath -ne $null)
$vm | get-cddrive | Set-CDDrive -NoMedia -Confirm:$False
}
else
#foreach ($vm in VMs){
# movevm -datastore $new_ds -DiskStorageFormat Thin -RunAsync
$VMs | move-vm -Datastore $new_ds -DiskStorageFormat Thin -RunAsync
}
do i have to do it one at a time for the isomount dismount?
You could do something like this
Import-Csv "C:\scripts\dsmigration.csv" -UseCulture -PipelineVariable row |
ForEach-Object -Process {
Get-VM -Datastore $row.old_ds |
ForEach-Object -Process {
Get-CDDrive -VM $_ | where{$_.IsoPath} | Set-CDDrive -NoMedia -Confirm:$false
Move-VM -Datastore $row.new_ds -DiskStorageFormat Thin -RunAsync
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference