Automation

 View Only
  • 1.  storage vmotions over 10 VMs

    Posted Jun 11, 2022 05:12 PM

    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



  • 2.  RE: storage vmotions over 10 VMs

    Posted Jun 11, 2022 05:56 PM

    The number of parallel svMotion is indeed limited, but the other ones should be queued and run in the end.
    Do you see differently?



  • 3.  RE: storage vmotions over 10 VMs

    Posted Jun 12, 2022 01:00 AM

    yes it does. I wanted to ad a progress bar to it



  • 4.  RE: storage vmotions over 10 VMs

    Posted Jun 12, 2022 08:00 AM

    What kind of progress bar?
    One for each of the background tasks, or one for all the tasks?



  • 5.  RE: storage vmotions over 10 VMs

    Posted Jun 12, 2022 04:07 PM

    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...



  • 6.  RE: storage vmotions over 10 VMs

    Posted Jun 12, 2022 04:09 PM

    Yes, that should work



  • 7.  RE: storage vmotions over 10 VMs

    Posted Jun 12, 2022 04:24 PM

    do i need a for loop for this to work on multiple ds? and can i add a progress bar per vm?



  • 8.  RE: storage vmotions over 10 VMs

    Posted Jun 12, 2022 04:58 PM

    Your sample code has a loop after the Import-Csv.



  • 9.  RE: storage vmotions over 10 VMs

    Posted Jun 13, 2022 06:11 PM

    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? 



  • 10.  RE: storage vmotions over 10 VMs

    Posted Jun 13, 2022 06:51 PM

    You could do something like this