Move-VM
Move-VM
Moves a virtual machine to a new Hyper-V host.
語法
Parameter Set: CompatibilityReport
Move-VM [-CompatibilityReport] <VMCompatibilityReport> [-AsJob] [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: NameMultipleDestinations
Move-VM [-Name] <System.String> [-DestinationHost] <System.String> [-AsJob] [-ComputerName <System.String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-DestinationCredential <System.Management.Automation.PSCredential> ] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-SmartPagingFilePath <System.String> ] [-SnapshotFilePath <System.String> ] [-Vhds <System.Collections.Hashtable[]> ] [-VirtualMachinePath <System.String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: NameMultipleDestinationsAndCimSession
Move-VM [-Name] <System.String> [-DestinationCimSession] <Microsoft.Management.Infrastructure.CimSession> -VirtualMachinePath <System.String> [-AsJob] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-SmartPagingFilePath <System.String> ] [-SnapshotFilePath <System.String> ] [-Vhds <System.Collections.Hashtable[]> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: NameSingleDestination
Move-VM [-Name] <System.String> [-DestinationHost] <System.String> [-AsJob] [-ComputerName <System.String[]> ] [-Credential <System.Management.Automation.PSCredential[]> ] [-DestinationCredential <System.Management.Automation.PSCredential> ] [-DestinationStoragePath <System.String> ] [-IncludeStorage] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: NameSingleDestinationAndCimSession
Move-VM [-Name] <System.String> [-DestinationCimSession] <Microsoft.Management.Infrastructure.CimSession> [-AsJob] [-CimSession <Microsoft.Management.Infrastructure.CimSession[]> ] [-DestinationStoragePath <System.String> ] [-IncludeStorage] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: VMMultipleDestinations
Move-VM [-VM] <Microsoft.HyperV.PowerShell.VirtualMachine> [-DestinationHost] <System.String> [-AsJob] [-DestinationCredential <System.Management.Automation.PSCredential> ] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-SmartPagingFilePath <System.String> ] [-SnapshotFilePath <System.String> ] [-Vhds <System.Collections.Hashtable[]> ] [-VirtualMachinePath <System.String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: VMMultipleDestinationsAndCimSession
Move-VM [-VM] <Microsoft.HyperV.PowerShell.VirtualMachine> [-DestinationCimSession] <Microsoft.Management.Infrastructure.CimSession> -VirtualMachinePath <System.String> [-AsJob] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-SmartPagingFilePath <System.String> ] [-SnapshotFilePath <System.String> ] [-Vhds <System.Collections.Hashtable[]> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: VMSingleDestination
Move-VM [-VM] <Microsoft.HyperV.PowerShell.VirtualMachine> [-DestinationHost] <System.String> [-AsJob] [-DestinationCredential <System.Management.Automation.PSCredential> ] [-DestinationStoragePath <System.String> ] [-IncludeStorage] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: VMSingleDestinationAndCimSession
Move-VM [-VM] <Microsoft.HyperV.PowerShell.VirtualMachine> [-DestinationCimSession] <Microsoft.Management.Infrastructure.CimSession> [-AsJob] [-DestinationStoragePath <System.String> ] [-IncludeStorage] [-Passthru] [-RemoveSourceUnmanagedVhds] [-ResourcePoolName <System.String> ] [-RetainVhdCopiesOnSource] [-Confirm] [-WhatIf] [ <CommonParameters>]
詳細描述
The Move-VM cmdlet moves a virtual machine to a new Hyper-V host.
參數
-AsJob
Runs the cmdlet as a background job.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-CimSession<Microsoft.Management.Infrastructure.CimSession[]>
在遠端工作階段或遠端電腦上執行 Cmdlet。輸入電腦名稱或工作階段物件,例如 New-CimSession 或 Get-CimSession Cmdlet 的輸出。預設為本機電腦上目前的工作階段。
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-CompatibilityReport<VMCompatibilityReport>
Specifies a compatibility report which includes any adjustments required for the move.
別名 |
none |
必要項? |
true |
位置? |
1 |
預設值 |
none |
接受管線輸入? |
True (ByValue) |
接受萬用字元? |
false |
-ComputerName<System.String[]>
Specifies one or more Hyper-V hosts that run this cmdlet. 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.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-Credential<System.Management.Automation.PSCredential[]>
Specifies one or more user accounts that have permission to perform this action. The default is the current user.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-DestinationCimSession<Microsoft.Management.Infrastructure.CimSession>
Specifies the CIMSession on the Hyper-V host to which the virtual machine is to be moved.
別名 |
none |
必要項? |
true |
位置? |
2 |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-DestinationCredential<System.Management.Automation.PSCredential>
Specifies a user account that has permission to perform this action. The default is the current user.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-DestinationHost<System.String>
Specifies the Hyper-V host to which the virtual machine is to be moved.
別名 |
none |
必要項? |
true |
位置? |
2 |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-DestinationStoragePath<System.String>
Specifies a destination storage path to which all virtual machine storage is to be moved.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-IncludeStorage
Specifies that both the virtual machine and its storage are to be moved.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-Name<System.String>
Specifies the friendly name of the virtual machine to be moved.
別名 |
none |
必要項? |
true |
位置? |
1 |
預設值 |
none |
接受管線輸入? |
true(ByValue) |
接受萬用字元? |
false |
-Passthru
Specifies that an object is to be passed through to be pipeline representing the moved virtual machine.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-RemoveSourceUnmanagedVhds
Indicates that Hyper-V deletes the parent virtual hard disk on the source after this cmdlet moves a differencing virtual hard disk, when the migration is finished.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-ResourcePoolName<System.String>
Specifies the name of the processor resource pool to be used.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-RetainVhdCopiesOnSource
Indicates that this cmdlet retains parent virtual hard disks on the source computer.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-SmartPagingFilePath<System.String>
Specifies the new path to use for a smart paging file, if one is needed.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-SnapshotFilePath<System.String>
Specifies the path for any snapshot files associated with the virtual machine.
別名 |
CheckpointFileLocation,SnapshotFileLocation |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-Vhds<System.Collections.Hashtable[]>
Specifies an array of hashtables that contain locations for each individual virtual hard disk to be moved. Each hashtable should have 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 name must be identical in both entries.
別名 |
none |
必要項? |
false |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-VirtualMachinePath<System.String>
Specifies the path where the virtual machine configuration files are to be stored.
別名 |
none |
必要項? |
true |
位置? |
named |
預設值 |
none |
接受管線輸入? |
false |
接受萬用字元? |
false |
-VM<Microsoft.HyperV.PowerShell.VirtualMachine>
Specifies the virtual machine to be moved.
別名 |
none |
必要項? |
true |
位置? |
1 |
預設值 |
none |
接受管線輸入? |
true(ByValue) |
接受萬用字元? |
false |
-Confirm
在執行指令程式之前提示您確認。
必要項? |
false |
位置? |
named |
預設值 |
false |
接受管線輸入? |
false |
接受萬用字元? |
false |
-WhatIf
示範當執行指令程式時會發生什麼事情。此指令程式並未執行。
必要項? |
false |
位置? |
named |
預設值 |
false |
接受管線輸入? |
false |
接受萬用字元? |
false |
<CommonParameters>
這個指令程式支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。如需詳細資訊,請參閱 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。
輸入
輸入類型是可透過管道傳送至指令程式的物件類型。
輸出
輸出類型是指令程式所發出的物件類型。
- None, by default. Microsoft.HyperV.PowerShell.VirtualMachine if the migration succeeds and -PassThru is specified. Microsoft.HyperV.PowerShell.CompatibilityReport if the migration fails because of an incompatibility.
範例
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"})