VMware Cloud Community
jpoling
Enthusiast
Enthusiast
Jump to solution

PowerCLI and vMotion

I am migrating VMs to new hosts using the move-vm cmdlet.  The one-liner I am using (courtesy of http://www.simple-talk.com/sysadmin/virtualization/10-steps-to-kick-start-your-vmware-automation-wit...) is:

Get-VMHost esx05 | Get-VM | Move-VM -Destination (Get-VMHost esx06)

What I see right now is that the VMs move one at a time.  Is tehre a way to get it to move more than one VM at a time?

Thanks,

Jeff

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Yes, use the RunAsync parameter on the Move-VM cmdlet.

Get-VMHost esx05 | Get-VM | Move-VM -Destination (Get-VMHost esx06) -RunAsync

There will still be only a limited number of migrations that runs concurrently, but that is a limitation of your vSphere environment.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

Yes, use the RunAsync parameter on the Move-VM cmdlet.

Get-VMHost esx05 | Get-VM | Move-VM -Destination (Get-VMHost esx06) -RunAsync

There will still be only a limited number of migrations that runs concurrently, but that is a limitation of your vSphere environment.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jpoling
Enthusiast
Enthusiast
Jump to solution

Thanks.  I saw that in the get-help for move-vm, but I wasn't exactly sure what it meant.

Jeff

0 Kudos
jpoling
Enthusiast
Enthusiast
Jump to solution

-runasync didn't exactly accomplish what I was expecting, but I found out it was because of a limitation.  I am moving VMs to a new cluster.  This KB article indicates that a resource pool can only have one vmotion at a time when moving between resource pools:

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=102610...

Jeff

0 Kudos
vmCalgary
Enthusiast
Enthusiast
Jump to solution

LucD

Hello again. My objective is to use the Move-VM from one datastore to another one at a time. My script is doing the equivalent to -RunAsync.

C:\> $VMsToRelocate = (Get-Content "C:\Users\username\Desktop\O6297-storage_vm\O6297_SVM.csv")

$Datastore = Get-Datastore -Name "st815zz_vcd_ds8"

foreach ($VM in $VMsToRelocate)

{

Write-Host "Relocating VM:" $VM "to" $Datastore

Get-VM -Name $VM | Move-VM -datastore $Datastore > $null

}

Write-Host "Completed!"

My file is a list of VM names:

VM1

VM2

VM3

It works but all at once. I want one at a time. What am I missing?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Do you see the svMotions (Relocate Virtual Machine) running at the same time in the Web Client?have any

Do you have any default parameters set?Check what is in $PSDefaultParameterValues


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
vmCalgary
Enthusiast
Enthusiast
Jump to solution

$PSDefaultParameterValues is empty.

I see them running concurrently in web client.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I thought I remembered a simiar thread, and this is th eone Re: Move VMs serially

There are a couple of possible solutions in that thread


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

vmCalgary
Enthusiast
Enthusiast
Jump to solution

Thanks as always.

0 Kudos