@@ -51,70 +51,21 @@ The **Import-VM** cmdlet imports a virtual machine from a file.
5151
5252### Example 1
5353```
54- PS C:\> Import-VM -Path 'D:\Test\VirtualMachines\5AE40946-3A98-428E-8C83-081A3C6BD18C.XML'
54+ PS C:\> Import-VM -Path 'C:\<vm export path>\2B91FEB3-F1E0-4FFF-B8BE-29CED892A95A.vmcx'
5555```
5656
5757Imports the virtual machine from its configuration file.
5858The virtual machine is registered in-place, so its files are not copied.
5959
6060### Example 2
6161```
62- PS C:\> Import-VM -Path 'D:\Test2\Virtual Machines\8F148B6D-C674-413E-9FCC-4FBED185C52D.XML ' -Copy -GenerateNewId
62+ PS C:\> Import-VM -Path 'C:\<vm export path>\2B91FEB3-F1E0-4FFF-B8BE-29CED892A95A.vmcx ' -Copy -GenerateNewId
6363```
6464
6565Imports the virtual machine by copying its files to the default virtual machine and virtual hard drive storage locations of the Hyper-V host.
6666The imported virtual machine will be given a new unique identifier, not the one in the configuration file.
6767This is useful when you want to import multiple copies of a virtual machine, since each virtual machine must have a unique identifier.
6868
69- ### Example 3
70- ```
71- Attempts import of a virtual machine; the attempt fails due to incompatibilities with the Hyper-V host.
72- PS C:\> Import-VM -Path 'D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XML'
73- Import-VM : Unable to import virtual machine due to configuration errors. Please use Compare-VM to repair the virtual machine.
74- At line:1 char:1
75- + import-vm -Path 'D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XM ...
76- + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77- + CategoryInfo : NotSpecified: (:) [Import-VM], VirtualizationOperationFailedException
78- + FullyQualifiedErrorId : Microsoft.HyperV.PowerShell.Commands.ImportVMCommand
79-
80- Gets a compatibility report that describes the attempted import and lists the virtual machine's incompatibilities with the Hyper-V host.
81- PS C:\> $report = Compare-VM -Path 'D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XML'
82-
83-
84- Displays the compatibility report, revealing that the virtual network adapter was connected to switch Production. The Hyper-V host has no switch by that name.
85- PS C:\> $report.Incompatibilities | Format-Table -AutoSize
86- Message MessageId Source
87- ------- --------- ------
88- Could not find Ethernet switch 'Production'. 33012 Microsoft.HyperV.PowerShell.VMNetworkAdapter
89-
90- Disconnects the virtual network adapter.
91- PS C:\> $report.Incompatibilities[0].Source | Disconnect-VMNetworkAdapter
92-
93-
94- Generates a new compatibility report to determine if the virtual machine is compatible with the Hyper-V host.
95- PS C:\> Compare-VM -CompatibilityReport $report
96-
97-
98- Displays the compatibility report.
99- PS C:\> $report
100- VM : Microsoft.HyperV.PowerShell.VirtualMachine
101- OperationType : ImportVirtualMachine
102- Destination : HYPER-V-1
103- Path : D:\vm1\Virtual Machines\53EAE599-4D3B-4923-B173-6AEA29CB7F42.XML
104- SnapshotPath : D:\vm1\Snapshots
105- VhdDestinationPath :
106- VhdSourcePath :
107- Incompatibilities :
108-
109- Imports the virtual machine.
110- PS C:\> import-vm -CompatibilityReport $report
111- Name State CPUUsage(%) MemoryAssigned(M) MemoryDemand(M) MemoryStatus Uptime Status ReplicationState
112- ---- ----- ----------- ----------------- --------------- ------------ ------ ------ ----------------
113- VM1 Off 0 0 0 00:00:00 Operating normally Disabled
114- ```
115-
116- Imports a virtual machine whose configuration is not compatible with the Hyper-V host.
117-
11869## PARAMETERS
11970
12071### -AsJob
0 commit comments