Editar

Compartir a través de


Import-VM

Imports a virtual machine from a file.

Syntax

Import-VM
      [-CimSession <CimSession[]>]
      [-ComputerName <String[]>]
      [-Credential <PSCredential[]>]
      [-Path] <String>
      [-Register]
      [-AsJob]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Import-VM
      [-CimSession <CimSession[]>]
      [-ComputerName <String[]>]
      [-Credential <PSCredential[]>]
      [-Path] <String>
      [[-VhdDestinationPath] <String>]
      [-Copy]
      [-VirtualMachinePath <String>]
      [-SnapshotFilePath <String>]
      [-SmartPagingFilePath <String>]
      [-VhdSourcePath <String>]
      [-GenerateNewId]
      [-AsJob]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-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.

Type:CimSession[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-CompatibilityReport

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

Type:VMCompatibilityReport
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-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.

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-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.

Type:SwitchParameter
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Credential

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

Type:PSCredential[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-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.)

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

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

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-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.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SmartPagingFilePath

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-SnapshotFilePath

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

Type:String
Aliases:CheckpointFileLocation, SnapshotFileLocation
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VhdDestinationPath

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

Type:String
Position:1
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VhdSourcePath

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VirtualMachinePath

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

Microsoft.HyperV.PowerShell.VirtualMachine