Manage Learn to apply best practices and optimize your operations.

Live-migrate Hyper-V VMs in and outside a failover cluster

PowerShell commands save time and enable admins to migrate multiple VMs outside a Hyper-V failover cluster from one host to another, as well as VMs inside the cluster between nodes.

You can use Hyper-V Manager to live migrate VMs one by one, but to live-migrate multiple VMs simultaneously, you...

have to use PowerShell. In this article, we provide a few PowerShell examples to help you live-migrate Hyper-V VMs operating in and outside of a failover cluster.

PowerShell provides the Move-VM PowerShell cmdlet to live-migrate a Hyper-V VM running on one host to another host, but Move-VM only works for VMs operating outside of a Hyper-V failover cluster. For example, VMs operating in a Hyper-V shared nothing live migration model are live-migrated using the following PowerShell command:

Move-VM "SQLVM" -DestinationHost <Hyper-VHostName> -DestinationStoragePath E:\MyVM1

The command shown above moves SQLVM to the Hyper-V host specified in the -DestinationHost parameter. While that command moves a single VM, the command shown below moves all VMs running on the local Hyper-V host to a remote Hyper-V host:

Get-VM -ComputerName <LostHyper-VHost> | Move-VM–DestinationHost <Hyper-VHostName> -DestinationStoragePath E:\MyVM1

These PowerShell commands are used to live-migrate Hyper-V VMs operating outside the failover cluster. If you need to live-migrate Hyper-V VMs from one node to another node in a cluster, use the Move-ClusterVirtualMachineRole PowerShell cmdlet as shown below:

Get-VM <SQLVM> | Move-ClusterVirtualMachineRole -MigrationType Live -Node <NodeName> -Wait 0

And to live-migrate multiple Hyper-V VMs in a failover cluster, use the following PowerShell command:

Get-VM | Move-ClusterVirtualMachineRole -MigrationType Live -Node <NodeName> -Wait 0

The -Wait 0 parameter above specifies that the PowerShell cmdlet runs and then returns to the PowerShell prompt without waiting.

This was last published in February 2018

Dig Deeper on Microsoft Hyper-V management

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

What are your best practices for live migrating Hyper-V VMs?