Move-VM

Move-VM

Moves a virtual machine to a new Hyper-V host.

Syntax

Parameter Set: Name
Move-VM [-Name] <String> [-DestinationHost] <String> [-AsJob] [-ComputerName <String[]> ] [-DestinationStoragePath <String> ] [-IncludeStorage] [-Passthru] [-ResourcePoolName <String> ] [-RetainVhdCopiesOnSource] [-SmartPagingFilePath <String> ] [-SnapshotFilePath <String> ] [-Vhds <Hashtable[]> ] [-VirtualMachinePath <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: CompatibilityReport
Move-VM [-CompatibilityReport] <VMCompatibilityReport> [-AsJob] [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: VM
Move-VM [-VM] <VirtualMachine> [-DestinationHost] <String> [-AsJob] [-DestinationStoragePath <String> ] [-IncludeStorage] [-Passthru] [-ResourcePoolName <String> ] [-RetainVhdCopiesOnSource] [-SmartPagingFilePath <String> ] [-SnapshotFilePath <String> ] [-Vhds <Hashtable[]> ] [-VirtualMachinePath <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Move-VM cmdlet moves a virtual machine to a new Hyper-V host.

Parameters

-AsJob

Specifies that the cmdlet is to be run as a background job.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-CompatibilityReport<VMCompatibilityReport>

Specifies a compatibility report which includes any adjustments required for the move.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-ComputerName<String[]>

Specifies one or more Hyper-V hosts from which the virtual machine is to be removed. NetBIOS names, IP addresses, and fully-qualified domain names are allowable. The default is the local computer — use “localhost” or a dot (“.”) to specify the local computer explicitly.

Aliases

none

Required?

false

Position?

named

Default Value

.

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DestinationHost<String>

Specifies the virtual machine host to which the virtual machine is to be moved.

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DestinationStoragePath<String>

Specifies a destination storage path to which all virtual machine storage is to be moved.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-IncludeStorage

Specifies that both the virtual machine and its storage are to be moved.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Name<String>

Specifies the friendly name of the virtual machine to be moved.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-Passthru

Specifies that an object is to be passed through to be pipeline representing the moved virtual machine.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VM<VirtualMachine>

Specifies the virtual machine to be moved.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-ResourcePoolName<String>

Specifies the name of the storage resource pool to use after the move operation is complete.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RetainVhdCopiesOnSource

Specify $true to keep any parent virtual hard disks on the source computer. If not specified, all virtual hard disks will be removed from the source computer once the virtual machine is successfully moved.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SmartPagingFilePath<String>

Specifies the new path to use for a smart paging file, if one is needed.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SnapshotFilePath<String>

Specifies the new path for any snapshot files associated with the virtual machine.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Vhds<Hashtable[]>

An array of hashtables that specifies a location for each individual virtual hard disk that needs to be moved. Each hashtable has two entries. The first entry specifies the current location of the virtual hard disk to move, and has a key of SourceFilePath. The second entry specifies the new location for the virtual hard disk, and has a key of DestinationFilePath. The virtual hard disk names must be identical in both entries.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VirtualMachinePath<String>

Specifies the path for the virtual machine configuration file and associated memory files.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

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.

  • None, by default. Microsoft.Virtualization.Powershell.VirtualMachine if the migration succeeds and -PassThru is specified. Microsoft.Virtualization.Powershell.CompatibilityReport if the migration fails because of an incompatibility.

Examples

Example 1

Moves a virtual machine test VM to a remote computer remoteServer when the virtual machine is stored on an SMB share.

PS C:\> Move-VM “Test VM” remoteServer

Example 2

Moves virtual machine test VM to remote computer remoteServer, and moves all files associated with the virtual machine to D:\TestVM on the remote computer.

PS C:\> Move-VM “Test VM” remoteServer –IncludeStorage –DestinationStoragePath D:\TestVM

Example 3

Moves a virtual machine Test VM to a remote computer remoteServer and places the files associated with the virtual machine in the specified locations under D:\TestVM on the remote computer.

PS C:\> Move-VM “Test VM” remoteServer –VirtualMachinePath D:\TestVM\Config –SnapshotFilePath D:\TestVM\Snapshots –SmartPagingFilePath D:\TestVM\SmartPaging –IncludeStorage –VHDs @(@{“SourceFilePath” = “C:\TestVM\Disk1.VHDX”; “DestinationFilePath” = “D:\TestVM\Disks\Disk1.VHDX”}, @{“SourceFilePath” = “C:\TestVM\Disk2.VHDX”; “DestinationFilePath” = “D:\TestVM\Disks\Disk2.VHDX”})