Move-VM a Hyper-V virtual machine configuration files

Move-VM

Move-VM PowerShell cmdlet helps you move a virtual machine with or without virtual machine storage to a remote Hyper-V host.

To move a virtual machine to a Hyper-V host named Hyper-Node2, execute the below command:

Move-VM "TestVM" Hyper-Node2 (This moves only Hyper-V virtual machine)

If you need to move a virtual machine as well as the storage of virtual machine to a remote Hyper-V host, use this command instead:

Move-VM "TestVM" Hyper-Node2 -IncludeStorage -DestinationStoragePath \\NutanixServer\Container\Hyper-V\TestVMFolder

In the above command, the -IncludeStorage parameter takes care of moving the virtual machine storage to the \\NutanixServer\Container\Hyper-V\TestVMFolder location on a remote Hyper-V host named Hyper-Node2. The only thing to consider is, this will not work for HA protected VM, the reason is in WFC, a virtual machine is treated as a shared cluster resource and nodes which are part of cluster are the one which understands it.

Some Additional Parameter

-CompatibilityReport, This parameter helps you understand any adjustments you might need to do on a destination Hyper-V host before the actual move takes place
-RetainVHDCopiesOnSource If you use this parameter in a Move-VM command, virtual hard disks for the virtual machine will not be deleted from the source Hyper-V host.

Move-VMStorage

The Move-VMStorage PowerShell cmdlet can be used if you want to move only virtual machine storage and if the storage is only on the local Hyper-V host.

Move-VMStorage "TestVM" -DestinationStoragePath \\NutanixServer\Container\Hyper-V\TestVMFolder
Move-VMStorage "TestVM" -VirtualMachinePath \\NutanixServer\Container\Hyper-V\TestVMFolder

Screen Shot 2017-06-02 at 11.02.19 AM
File Path

  • SnapShotFilePath – Allows you to specify the new path for any snapshot files that are associated with the virtual machine.
  • VirtualMachinePath – Use this if you want to store the virtual machine configuration file (XML) to an alternate location on the Hyper-V host.
  • DestinationStoragePath – Allows you to copy virtual hard disk files to an alternate path on the Hyper-V host.
  • SmartPagingFile – As the name suggests, use this parameter to allow Move-VMStorage to move the paging file of virtual machines to an alternate location on the Hyper-V host.
Move-VMStorage "TestVM" -VirtualMachinePath \\NutanixServer\Container\Hyper-V\TestVMFolder\VMConfigFile -SnapshotFilePath \\NutanixServer\Container\Hyper-V\TestVMFolder\SnapShotFiles -SmartPagingFilePath \\NutanixServer\Container\Hyper-V\TestVMFolder\SmartPaging

Compare-VM helps you compare a virtual machine compatibility with a Hyper-V host. This is a very useful cmdlet that you can use before moving a virtual machine to a remote Hyper-V host.

Compare-VM

$Report = Compare-VM <TestVM> -DestinationHost Hyper-Node2 -DestinationStoragePath \\NutanixServer\Container\Hyper-V\TestVMFolder -IncludeStorage

 

Advertisements