Here’s a command for moving a VM within a cluster without using Live Migration.
The command is Move-VM, and parameter to use is –UseCluster. See the excerpt below.
Something to save for a rainy day.
*WINDOWS SERVER 2008 R2 Hyper-V LIVE MIGRATION
– If a virtual machine is running and is deployed on a Hyper-V host that is a node of a Windows Server 2008 R2 host cluster, by default, VMM 2008 R2 will use Hyper-V live migration to move the virtual machine to another node in the cluster without any disruption of service, such as disconnecting from the network, or perceived downtime for users. You do not need to specify a path for this type of move. Windows 2008 Cluster Migration can be used when live migration is not available or if the virtual machine is stopped.
- To force the virtual machine to be moved using Windows 2008 Cluster Migration, use the -UseCluster parameter of the Move-VM cmdlet. Windows 2008 Cluster Migration (sometimes called Quick Migration) places the virtual machine in a saved state during migration, causing a temporary loss of service to any users of that virtual machine. For more information about Hyper-V live migration, see http://go.microsoft.com/fwlink/?LinkId=147115.
Move-VM
SYNOPSIS Moves a virtual machine stored in the Virtual Machine Manager library or de ployed on a host server to a new location on a host server. SYNTAX Move-VM [-VM] [<String VM>] -VMHost [<String Host>] [-BlockLMIfHostBusy] [- JobGroup <Guid>] [-JobVariable <String>] [-Path <String>] [-PROTipID <Guid> ] [-RunAsynchronously] [-StartVMOnTarget] [-UseCluster] [-UseLAN] [<CommonP arameters>] DESCRIPTION Moves a virtual machine stored in the Virtual Machine Manager library or de ployed on a host server to a new location on a host server. Alternatively, if you want to move a virtual machine from a host and store it in the libra ry, you must use the Store-VM cmdlet. When you use the Move-VM cmdlet on a running virtual machine that is on a c lustered Windows Server 2008 R2 host, VMM will attempt to move the virtual machine using Hyper-V live migration. If Hyper-V live migration is not avai lable, VMM will attempt to use Cluster Migration to move the virtual machin e. If neither of these methods is available, then you must put the virtual machine in a stopped or saved state to move it. For virtual machines on ES X Server hosts with shared storage, VMM attempts to use the VMware live mig ration feature. VMM 2008 R2 can use any of the following transfer methods (listed in the or der in which VMM tries to use them): *WINDOWS SERVER 2008 R2 Hyper-V LIVE MIGRATION – If a virtual machine is running and is deployed on a Hyper-V host that is a node of a Windows Server 2008 R2 host cluster, by default, VMM 2008 R2 will use Hyper-V live migration to move the virtual machine to another node in the cluster without any disruption of service, such as disconnecting from the network, or perceived downtime for users. You do not need to specify a path for this type of move. Windows 2008 Cluster Migration can be used when live migration is not available or if the virtual machine is stopped. To force the virtual machine to be moved using Windows 2008 Cluster Migration, use the -UseCluster parameter of the Move-VM cmdlet. Windows 2008 Cluster Migration (sometimes called Quick Migration) places the virtual machine in a saved state during migration, causing a temporary loss of service to any users of that virtual machine. For more information about Hyper-V live migration, see http://go.microsoft.com/fwlink/?LinkId=147115. * WINDOWS 2008 CLUSTER MIGRATION – If a virtual machine is deployed on a Hyper-V host that is one node on a host cluster, VMM can use Windows Server 2008 Cluster Migration (sometimes called Quick Migration) to move the virtual machine to another node in the cluster. You do not need to specify a path for this type of move. * VMWARE LIVE MIGRATION – If a virtual machine deployed on a VMware ESX Server host uses shared storage, VMM can use the VMware live migration feature (also called VMotion) to move the virtual machine to a new host. You do not need to specify a path for this type of move. The Move-VM cmdlet can use the VMware VMotion feature to move a virtual machine from one ESX Server host to another only if both ESX Server hosts are in the same Datacenter container on the VMware VirtualCenter Server. * SAN MIGRATION (Fibre Channel, iSCSI, or NPIV) – If the virtual machine is on a host that is connected to a SAN and the virtual machine is on a SAN LUN, VMM can move that virtual machine to another host if that host has access to the same SAN. In a SAN transfer, the target LUNs are redirected from the source host to the destination host (no files are moved), which is why a SAN transfer is much faster than moving virtual machine files from one host to another over a local area network (LAN). You must specify a path for this type of move. VMM can use an NPIV SAN transfer if a host bus adapter (HBA)with NPIV support is available. * NETWORK MIGRATION – If no faster method is available, VMM uses a network transfer to move the virtual machine files from one host to another over the LAN that connects the two hosts. You can choose to use this transfer type even if the SAN transfer type is available. You must specify a path for this type of move. When more than one transfer type is available, the Move-VM cmdlet automatic ally uses the fastest available transfer type to move a virtual machine. If the first method is not appropriate or available for the virtual machine y ou want to move, VMM tries to use the next method, and so on. If you want t o force the use of a network transfer, specify the -UseLAN parameter. PARAMETERS -VM [<String VM>] Specifies a virtual machine object. -VMHost [<String Host>] Specifies a virtual machine host object. VMM 2008 supports Hyper-V host s, Virtual Server hosts, and VMware ESX Server hosts. For more informat ion about each type of host, type: Get-Help Add-VMHost -detailed. See t he examples for a specific cmdlet to determine how that cmdlet uses thi s parameter. -BlockLMIfHostBusy If a Hyper-V live migration is in progress and a new migration cannot b e started immediately, do not attempt to retry the migration. -JobGroup <Guid> Specifies an identifier for a series of commands that will run as a set just before the final command that includes the same job group identif ier runs. For information about how VMM uses job groups, including a li st of job groups available for specific cmdlets, type: Get-Help about_V MM -JobVariable <String> Specifies that job progress is tracked and stored in the variable named by this parameter. -Path <String> Specifies the destination path for the operation. Example formats (the specific format or formats you can you use might d iffer by cmdlet): Local path -Path "F:\" UNC path -Path "\\Library\Templates" Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e 3}\" VMware ESX path –Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx" Note: See the examples for a specific cmdlet to determine how that cmdl et specifies the path. -PROTipID <Guid> Specifies the ID of the PRO tip that triggered this action. Allows for future auditing of PRO tips. -RunAsynchronously Specifies that the job runs asynchronously so that control returns to t he command shell immediately. -StartVMOnTarget Specifies that a virtual machine starts as soon as it reaches its desti nation host. -UseCluster Forces a transfer of the virtual machine using Windows 2008 Cluster Mig ration (sometimes called Quick Migration) with a saved state even if Hy per-V live migration is available on the cluster. -UseLAN Forces a transfer over the local area network (LAN) even if a faster tr ansfer mechanism, such as a storage area network (SAN) transfer, is ava ilable. <CommonParameters> This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters". EXAMPLE 1: Move a virtual machine from the library to a host. PS C:\> Get-VMMServer -ComputerName "VMMServer1.Contoso.com" PS C:\> $VM = Get-VM | where { $_.Name -eq "VM01" -and $_.LibraryServer -eq "FileServer01.Contoso.com" } PS C:\> $VMHost = Get-VMHost -ComputerName "VMHost01.Contoso.com" PS C:\> Move-VM -VMHost $VMHost -VM $VM -Path "D:\VMs" The first command connects to VMMServer1 in the Contoso.com domain and gets the server object from the VMM database. The following commands use this s erver by default. The second command gets from the VMM database the object that represents th e virtual machine named VM01 (which is currently stored in the VMM library on the library server named FileServer01) and stores the virtual machine ob ject in variable $VM. This example assumes that only one virtual machine na med VM01 is currently stored on FileServer01, and that, therefore, Get-VM r etrieves only one object. The third command gets the object that represents the host named VMHost01 a nd stores the host object in variable $VMHost. The last command moves the virtual machine from its current location in the library to the location D:\VMs on the host. The command automatically uses the fastest available transfer type. When the command completes, it return s information about the moved virtual machine to the screen, including the MostRecentTask, which contains "Move virtual machine from <YourLibraryServe rName> to <YourVMHostName>." NOTE: If you want to move a virtual machine that is currently deployed on a host to another location and neither VMotion nor Quick Migration is availa ble, the virtual machine must be turned off or put in a saved state before it can be moved. If you want to move a virtual machine that is currently de ployed on a host into the VMM library, you must use the Store-VM cmdlet. EXAMPLE 2: Move a virtual machine from the library to a host asynchronously. PS C:\> Get-VMMServer -ComputerName "VMMServer1.Contoso.com" PS C:\> $VM = Get-VM | where { $_.Name -eq "VM02" -and $_.LibraryServer -eq "FileServer02.Contoso.com" } PS C:\> $VMHost = Get-VMHost -ComputerName "VMHost02.Contoso.com" PS C:\> Move-VM -VMHost $VMHost -VM $VM -Path "D:\VMs" -RunAsynchronously - JobVariable "MyJob" PS C:\> $MyJob The first four commands in this example are identical to the commands in ex ample 1, except that when the fourth command moves the virtual machine from its current location to D:\VMs on VMHost02, it also uses the RunAsynchrono usly parameter to return control to the command shell immediately, and it u ses the JobVariable parameter to track job progress and store a record of i ts progress in variable MyJob. For the JobVariable parameter, you do not us e the dollar sign ($) when the variable is created. The last command displays the contents of $MyJob, which includes a descript ion of the move job, its status ("Running"), and other information. EXAMPLE 3: Move a virtual machine from the library to a host by forcing a L AN transfer. PS C:\> Get-VMMServer -ComputerName "VMMServer1.Contoso.com" PS C:\> $VMHost = Get-VMHost -ComputerName "VMHost03.Contoso.com" PS C:\> Move-VM -VMHost $VMHost -VM "VM03" -Path "D:\VMs" -UseLAN The first command connects to VMMServer1. The second command gets the object that represents the host named VMHost03 and stores the host object in $VMHost. The last command moves the virtual machine VM03 (by specifying its name) fr om its current location in the library to D:\VMs on VMHost03, it uses the U seLAN parameter to specify that the transfer uses a network transfer (even if faster transfer mechanisms are available). This example assumes that VM0 3 was stored in the VMM library before the move operation started. EXAMPLE 4: Move a virtual machine between hosts by using VMware VMotion. PS C:\> Get-VMMServer -ComputerName "VMMServer1.Contoso.com" PS C:\> $VM = Get-VM -Name "VM04" | where {$_.VMHost.Name -eq "10.199.53.11 "} PS C:\> $VMHost = Get-VMHost | where {$_.Name -eq "10.199.53.12"} PS C:\> Move-VM -VM $VM -VMHost $VMHost PS C:\> Move-VM -VM $VM -VMHost $VMHost -Path "[Storage2]\VM04\VM04.vmx" The first command connects to VMMServer1. The second command gets the object that represents the virtual machine name d VM04 (which is currently running on the VMWare ESX host identified by its IP address, 10.199.53.11) and stores the virtual machine object in $VM. The third command gets the object that represents the ESX host identified by IP address10.100.53.12 and stores the host object in $VMHost. In the last command, the Move-VM cmdlet uses VMware VMotion to move the vir tual machine from its current ESX host to the other ESX host. IMPORTANT: The Move-VM cmdlet can use the VMware VMotion feature to move a virtual machine from one ESX host to another only if both ESX servers are i n the same Datacenter container on the VMware VirtualCenter Server. EXAMPLE 5: Move a highly available VM between nodes in a host cluster by us ing Hyper-V quick migration. PS C:\> Get-VMMServer -ComputerName "VMMServer1.Contoso.com" PS C:\> $VM = Get-VM -Name "HAVM05" | where {$_.VMHost.Name -eq "VMHVHostNo de05A.Contoso.com"} PS C:\> $VMHost = Get-VMHost | where {$_.Name -eq "VMHVHostNode05B.Contoso. com"} PS C:\> Move-VM -VM $VM -VMHost $VMHost The first command connects to VMMServer1. The second command gets the object that represents the virtual machine name d HAVM05 (which is currently running on the Hyper-V host named VMHVHostNode 05A) and stores the virtual machine object in $VM. This example assumes tha t HAVM05 is a highly available virtual machine and that VMHVHostNode05A and VMHVHostNode05B are nodes in a Hyper-V host cluster. The third command gets the object that represents the host named VMHVHostNo de05B and stores the host object in $VMHost. In the last command, the Move-VM cmdlet uses Windows Server 2008 quick migr ation to move the virtual machine from VMHVHostNode05A to VMHVHostNode05B. 6: Move a running VM on a Hyper-V host to a new location on the same host. PS C:\> Get-VMMServer "VMMServer1.Contoso.com" PS C:\> $MoveVhdPath = "E:\” PS C:\> $VM = Get-VM “VM06” PS C:\> $VMHost = Get-VMHost “VirtualHost.Local.Lab” PS C:\> $HostPath = "D:\MyVMs" PS C:\> $JobGroupID = [System.Guid]::NewGuid().ToString() PS C:\> Move-VirtualHardDisk -IDE -Bus 1 -Lun 1 -Path $MoveVhdPath -JobGrou p $JobGroupID PS C:\> Move-VM -VM $VM -VMHost $VMHost -Path $HostPath -JobGroup $JobGroup ID The first command connects to VMMServer1. The second command stores the string "E:\” in $MoveVhdPath. This is the pat h to which you want to move the virtual hard disk of VM06. The third command stores the object that represents VM06 in $VM. The fourth command stores the object that represents VMHost06 in $VMHost. T his example assumes that VMHost06 is a Hyper-V host. The fifth command stores the string "D:\MyVMs" in $HostPath. This is the pa th to which you want to move VM06. The sixth command creates a new GUID string and stores it in $JobGroupID. T his GUID is a job group ID that functions as an identifier that groups subs equent commands that include this identifier into a single job group. The seventh command will set the virtual hard disk path to the value (E:\) in $MoveVhdPath and will connect the virtual hard disk to Bus 1 and LUN 1 o n the virtual IDE controller on the VM. NOTE: The preceding command uses the JobGroup parameter to specify that thi s command does not actually run until the Set-VM cmdlet triggers the execut ion of any commands in the JobGroup list. The last command runs any commands that contain $JobGroupID (in this case, Move-VirtualHardDisk) and runs Move-VM. The result is that VM06 (a running VM) is moved from its current location to D:\MyVMs on the same host. The vi rtual machine’s virtual hard disk is moved to E:\. NOTE: You can also move a running VM from one Hyper-V host to another Hyper -V host. REMARKS To see the examples, type: "get-help Move-VM -examples". For more information, type: "get-help Move-VM -detailed".