Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Import-VM

Module:
Hyper-V Module

Imports a virtual machine from a file.

Syntax

Register (Default)

Import-VM
 [-Path] <String>
 [-CimSession <CimSession[]>]
 [-ComputerName <String[]>]
 [-Credential <PSCredential[]>]
 [-Register]
 [-AsJob]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

Copy

Import-VM
 [-Path] <String>
 [[-VhdDestinationPath] <String>]
 [-CimSession <CimSession[]>]
 [-ComputerName <String[]>]
 [-Credential <PSCredential[]>]
 [-Copy]
 [-VirtualMachinePath <String>]
 [-SnapshotFilePath <String>]
 [-SmartPagingFilePath <String>]
 [-VhdSourcePath <String>]
 [-GenerateNewId]
 [-AsJob]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

CompatibilityReport

Import-VM
 [-CompatibilityReport] <VMCompatibilityReport>
 [-AsJob]
 [-WhatIf]
 [-Confirm]
 [<CommonParameters>]

Description

The Import-VM cmdlet imports a virtual machine from a file.

Examples

Example 1

PS C:\> Import-VM -Path 'C:\<vm export path>\2B91FEB3-F1E0-4FFF-B8BE-29CED892A95A.vmcx'

Imports the virtual machine from its configuration file. The virtual machine is registered in-place, so its files are not copied.

Example 2

PS C:\> Import-VM -Path 'C:\<vm export path>\2B91FEB3-F1E0-4FFF-B8BE-29CED892A95A.vmcx' -Copy -GenerateNewId

Imports the virtual machine by copying its files to the default virtual machine and virtual hard drive storage locations of the Hyper-V host. The imported virtual machine will be given a new unique identifier, not the one in the configuration file. This is useful when you want to import multiple copies of a virtual machine, since each virtual machine must have a unique identifier.

Parameters

-AsJob

Runs the cmdlet as a background job.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-CimSession

Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.

Parameter properties

Type:

CimSession[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-CompatibilityReport

Specifies a compatibility report which resolves any incompatibilities between the virtual machine and the Hyper-V host.

Parameter properties

Type:VMCompatibilityReport
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-ComputerName

Specifies one or more Hyper-V hosts from which the virtual machine is to be imported. 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.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

-Copy

Specifies that the imported virtual machine's files should be copied to the server's default locations, as opposed to registering the virtual machine in-place.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Credential

Specifies one or more user accounts that have permission to perform this action. The default is the current user.

Parameter properties

Type:

PSCredential[]

Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-GenerateNewId

Specifies that the imported virtual machine should be copied and given a new unique identifier. (By default, Import-VM gives the new virtual machine the same unique identifier as the imported virtual machine.)

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Path

Specifies the path to the exported virtual machine to be imported.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-Register

Specifies that the imported virtual machine is to be registered in-place, as opposed to copying its files to the server's default locations. Choose this option if the virtual machines files are already in the location from which they are to run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-SmartPagingFilePath

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-SnapshotFilePath

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:CheckpointFileLocation, SnapshotFileLocation

Parameter sets

-VhdDestinationPath

Specifies the folder to which the virtual machine's VHD files are to be copied.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-VhdSourcePath

Specifies the folder from which the virtual machine's VHD files are to be copied.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-VirtualMachinePath

Specifies the path where the virtual machine configuration files are to be stored.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-WhatIf

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

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

None

Outputs

Microsoft.HyperV.PowerShell.VirtualMachine


Feedback

Was this page helpful?