Move-SCVirtualMachine
Move-SCVirtualMachine
Moves a virtual machine stored in the VMM library or deployed on a host to a new location on a host.
Syntax
Parameter Set: Default
Move-SCVirtualMachine [-VM] <VM> [-BlockLiveMigrationIfHostBusy] [-HighlyAvailable <Boolean> ] [-JobGroup <Guid> ] [-JobVariable <String> ] [-Path <String> ] [-PROTipID <Guid> ] [-RunAsynchronously] [-StartVMOnTarget] [-UseCluster] [-UseLAN] [-VMHost <Host> ] [ <CommonParameters>]
Detailed Description
The Move-SCVirtualMachine cmdlet moves a virtual machine stored in the Virtual Machine Manager (VMM) library or deployed on a host to a new location on a host.
In System Center 2012 Service Pack 1 (SP1), you can take advantage of new migration capabilities included in Windows Server 2012, such as live migration of virtual machines between two standalone computers, or live migration between standalone computers and a cluster node. Additionally, multiple concurrent live migrations are supported. For more information about migrating virtual machines in System Center 2012 SP1, see Migrating virtual machines and storage in the TechNet Library.
NOTE: If you move a virtual machine deployed on a host running Windows Server 2008 R2 to a host running Windows Server 2012, you cannot move the virtual machine back to a host running Windows Server 2008 R2.
VMM includes storage migration features that let you move one or more virtual hard disks of a running virtual machine to a new location. You can use the Move-SCVirtualMachine cmdlet with the Move-SCVirtualHardDisk cmdlet to move Windows-based virtual hard disk (.vhd) files and VMware-based virtual hard disk (.vmdk) files to a location on a different host. If the virtual machine is deployed on a host running Windows Server 2008 R2 or Windows Server 2012 the virtual machine experiences minimal service interruption. If the virtual machine is deployed on a VMware ESX host, VMM uses VMware VMotion so that no service interruption occurs. You can also use the Move-SCVirtualHardDisk cmdlet to move a .vhd file or a .vmdk file from one location to another on the same host.
NOTE: To move a virtual machine from a host and store it in the library, you must use the Save-SCVirtualMachine cmdlet.
VMM can use any of the following transfer methods (listed in the order in which VMM tries to use them):
- 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 or Windows Server 2012 host cluster, by default, VMM will use Hyper-V live
migration to move the virtual machine to another node in the cluster
without any disruption of service, for example, moving a running
virtual machine will not disconnect it from the network. Additionally,
the virtual machine will retain its high availablility attribute on the
virtual machine. You do not need to specify a path for this type of
move. You can start live migration of multiple virtual
machines at the same time.
- WINDOWS SERVER 2008 CLUSTER MIGRATION – System Center 2012
continues to support Windows 2008 Cluster
Migration (sometimes called Quick Migration). Cluster Migration
lets you move a running virtual machine on a Hyper-V node of a
host cluster. It also lets you move a virtual machine that is in a
stopped or saved state and that is deployed to another node
in the cluster. You can use Cluster Migration to move a virtual
machine in a stopped or saved state if the virtual machine is
deployed on either of the following nodes:
* A node in a Windows Server 2008 cluster
* A node in a Windows Server 2008 R2 cluster
You do not need to specify a path for this type of move. Windows
Server 2008 Cluster Migration places the virtual machine in a
saved state during migration, which causes a temporary loss of
service to any users of that virtual machine.
- VMWARE LIVE MIGRATION – If a virtual machine deployed on a VMware
ESX host uses shared storage, VMM can use the VMware live
migration feature (VMware 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-SCVirtualMachine cmdlet can use VMware VMotion to move a
virtual machine from one ESX host to another only if both ESX
hosts are in the same Datacenter container on the vCenter Server.
- CITRIX XENSERVER XENMOTION – If a virtual machine deployed on a
Citrix XenServer host uses shared storage and is part of the same
Resource Pool, VMM can use the XenServer live migration feature
(Citrix XenMotion) to move the virtual machine to a new host.
You do not need to specify a path for this type of move. The
Move-SCVirtualMachine cmdlet can use Citrix XenMotion to move a
virtual machine from one XenServer host to another only if both
XenServer hosts are in the same Resource Pool.
This is the only supported method for moving a virtual machine
directly between XenServer hosts in VMM.
- 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).
VMM supports SAN migration of virtual machines into and
out of a cluster.
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-SCVirtualMachine cmdlet automatically uses the fastest available transfer type to move a virtual machine. If the first method is not appropriate or available for the virtual machine you want to move, VMM tries to use the next method, and so on. If you want to force the use of a network transfer, specify the UseLAN parameter.
Parameters
-BlockLiveMigrationIfHostBusy
Blocks retrying a Hyper-V live migration if the migration failed because the source host or the destination host is already participating in another live migration.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-HighlyAvailable<Boolean>
Specifies that a virtual machine will be placed on a Hyper-V host that is part of a host cluster. Configure this setting on a virtual machine, or on a template or hardware profile that will be used to create virtual machines.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-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 identifier runs.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-JobVariable<String>
Specifies that job progress is tracked and stored in the variable named by this parameter.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Path<String>
Specifies the destination path for the operation.
Example formats:
Local path -Path "F:\"
UNC path -Path "\\Library\Templates"
Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"
VMware ESX path –Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"
Citrix XenServer path - Path “Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]”
Wildcards are supported for "Get" cmdlets and when you specify the UNC path:
Example format:
UNC path -Path "\\VMHostServer\MyVMs\*VM*"
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-PROTipID<Guid>
Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-RunAsynchronously
Indicates that the job runs asynchronously so that control returns to the command shell immediately.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-StartVMOnTarget
Specifies that a virtual machine starts as soon as it reaches its destination host.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-UseCluster
Forces the use of Cluster Migration for the transfer of a virtual machine that is in a saved state to a host, even if the cluster supports Hyper-V live migration.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-UseLAN
Forces a transfer over the local area network (LAN) even if a faster transfer mechanism, such as a storage area network (SAN) transfer, is available.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-VM<VM>
Specifies a virtual machine object.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
True (ByValue) |
Accept Wildcard Characters? |
false |
-VMHost<Host>
Specifies a virtual machine host object. VMM supports Hyper-V hosts, VMware ESX hosts, and Citrix XenServer hosts.
For more information about each type of host, type: "Get-Help Add-SCVMHost -detailed". See the examples for a specific cmdlet to determine how that cmdlet uses this parameter.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
True (ByValue) |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
- VirtualMachine
Examples
1: Move a virtual machine from the library to a host.
The first command command gets the virtual machine object named VM01, which is currently stored in the VMM library on the library server named LibServer01, and stores the object in the $VM variable. This example assumes that only one virtual machine named VM01 is currently stored on LibServer01, and that, therefore, Get-SCVirtualMachine retrieves only one object.
The second command gets the host object named VMHost01 and stores the object in the $VMHost variable.
The last command moves the virtual machine from its current location in the library to the location D:\VirtualMachinePath on the host stored in $VMHost. The command automatically uses the fastest available transfer type. When the command completes, it returns information about the moved virtual machine.
PS C:\> $VM = Get-SCVirtualMachine | where { $_.Name -eq "VM01" -and $_.LibraryServer -eq "LibServer01.Contoso.com" }
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost01.Contoso.com"
PS C:\> Move-SCVirtualMachine -VMHost $VMHost -VM $VM -Path "D:\VirtualMachinePath"
2: Move a virtual machine from the library to a host asynchronously.
The first two commands in this example are identical to the commands in example 1, except for the name of the VM host.
When the third command moves the virtual machine from its current location to D:\VirtualMachinePath on VMHost02, it uses the RunAsynchronously parameter to return control to the command shell immediately, and the JobVariable parameter to track the progress of the job. JobVariable stores a record of the job progress in the MoveVMJob variable. For the JobVariable parameter, you do not use the dollar sign ($) when the variable is created.
The last command displays the contents of $MoveVMJob, which includes a description of the move job, its status, its progress, and other information.
PS C:\> $VM = Get-SCVirtualMachine | where { $_.Name -eq "VM01" -and $_.LibraryServer -eq "LibServer01.Contoso.com" }
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost02.Contoso.com"
PS C:\> Move-SCVirtualMachine -VMHost $VMHost -VM $VM -Path "D:\VirtualMachinePath" -RunAsynchronously -JobVariable "MoveVMJob"
PS C:\> $MoveVMJob
3: Move a virtual machine from the library to a host by forcing a LAN transfer.
The first command gets the virtual machine object named VM03 on library server LibServer01 and stores the object in the $VM variable.
The second command gets the host object named VMHost03 and stores the object in the $VMHost variable.
The last command moves the virtual machine VM03 from its current location in the library to D:\VirtualMachinePath on VMHost03 using the UseLAN parameter to specify that the transfer use a network transfer even if faster transfer mechanisms are available.
PS C:\> $VM = Get-SCVirtualMachine | where { $_.Name -eq "VM03" -and $_.LibraryServer -eq "LibServer01.Contoso.com" }
PS C:\> $VMHost = Get-SCVMHost -ComputerName "VMHost03.Contoso.com"
PS C:\> Move-SCVirtualMachine -VMHost $VMHost -VM $VM -Path "D:\VirtualMachinePath" -UseLAN
4: Move a virtual machine between hosts by using VMware VMotion.
The first gets the virtual machine object named VM04 on ESXHost01 and stores the object in the $VM variable.
The second command gets the ESX host object named ESXHost02 and stores the object in the $VMHost variable.
In the last command, the Move-SCVirtualMachine cmdlet uses VMware VMotion to move the virtual machine from its current ESX host to the other ESX host.
NOTE: The Move-SCVirtualMachine cmdlet can use the VMware VMotion feature to move a virtual machine from one ESX host to another only if both ESX servers are in the same Datacenter container on the vCenter Server.
PS C:\> $VM = Get-SCVirtualMachine -Name "VM04" | where {$_.VMHost.Name -eq "ESXHost01"}
PS C:\> $VMHost = Get-SCVMHost | where {$_.Name -eq "ESXHost02"}
PS C:\> Move-SCVirtualMachine -VM $VM -VMHost $VMHost -Path "[Storage2]"
5: Move a highly available virtual machine between nodes in a host cluster by using Hyper-V live migration.
The first command gets the virtual machine object named HAVM05 on VMHVHostNode05A and stores the in the $VM variable. This example assumes that HAVM05 is a highly available virtual machine and that VMHVHostNode05A and VMHVHostNode05B are nodes in a Hyper-V host cluster.
The second command gets the host object named VMHVHostNode05B and stores the object in the $VMHost variable.
In the last command, the Move-SCVirtualMachine cmdlet uses live migration to move the virtual machine from VMHVHostNode05A to VMHVHostNode05B.
PS C:\> $VM = Get-SCVirtualMachine -Name "HAVM05" | where {$_.VMHost.Name -eq "VMHVHostNode05A.Contoso.com"}
PS C:\> $VMHost = Get-SCVMHost | where {$_.Name -eq "VMHVHostNode05B.Contoso.com"}
PS C:\> Move-SCVirtualMachine -VM $VM -VMHost $VMHost -Path "D:\VMs\"
6: Move a running virtual machine on a Hyper-V host to a new location on the same host.
The first command stores the string "E:\VHDs" in $MoveVhdPath. This is the path to which you want to move the virtual hard disk of the virtual machine.
The second command gets the virtual machine object named VM06 and stores the object the $VM variable.
The third command gets the host object named VMHost06 and stores the object in the $VMHost variable. This example assumes that VMHost06 is a Hyper-V host.
The fourth command stores the string "E:\VirtualMachinePath" in the $HostPath variable. This is the path to which you want to move VM06.
The fifth command creates a new GUID string and stores it in the $JobGroupID variable. This GUID is a job group ID that functions as an identifier that groups subsequent commands that include this identifier into a single job group.
The sixth command sets the virtual hard disk path to the value stored in $MoveVhdPath and it connects the virtual hard disk to Bus 1 and LUN 1 on the virtual IDE controller on the virtual machine. This command uses the JobGroup parameter to specify that it does not actually run until the Move-SCVirtualMachine cmdlet triggers the running of any commands in the JobGroup list.
The last command runs any commands that contain $JobGroupID (in this case, Move-SCVirtualHardDisk), and it runs Move-SCVirtualMachine. As a result, VM06 (a running virtual machine) is moved from its current location to E:\VirtualMachinePath on the same host. The virtual machine’s virtual hard disk is moved to E:\VHDs.
NOTE: You can also move a running virtual machine from one Hyper-V host to another Hyper-V host.
PS C:\> $MoveVhdPath = "E:\VHDs”
PS C:\> $VM = Get-SCVirtualMachine “VM06”
PS C:\> $VMHost = Get-SCVMHost “VMHost06”
PS C:\> $HostPath = "E:\VirtualMachinePath"
PS C:\> $JobGroupID = [System.Guid]::NewGuid().ToString()
PS C:\> Move-SCVirtualHardDisk -IDE -Bus 1 -Lun 1 -Path $MoveVhdPath -JobGroup $JobGroupID
PS C:\> Move-SCVirtualMachine -VM $VM -VMHost $VMHost -Path $HostPath -JobGroup $JobGroupID