Convert-VHD

Convert-VHD

Converts the format, version type, and block size of a virtual hard disk file.

Syntax

Parameter Set: Default
Convert-VHD [-Path] <String> [-DestinationPath] <String> [-AsJob] [-BlockSizeBytes <UInt32> ] [-ComputerName <String[]> ] [-DeleteSource] [-ParentPath <String> ] [-Passthru] [-VHDType <VhdType> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The Convert-VHD cmdlet converts a virtual hard disk file by copying the data from a source virtual hard disk file to a new virtual hard disk file of a specified format and version type. The format is determined by the file extension of the specified files, either .vhdx or .vhd. Conversion is an offline operation; the virtual hard disk must not be attached when the operation is started.

Parameters

-AsJob

Runs the operation as a background job.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-BlockSizeBytes<UInt32>

Specifies the block size, in bytes, of the virtual hard disk after conversion.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String[]>

Specifies one or more Hyper-V hosts on which the virtual hard disk is to be converted. 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

-DeleteSource

Specifies that the source virtual hard disk is to be deleted after the conversion.

Aliases

none

Required?

false

Position?

named

Default Value

FALSE

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DestinationPath<String>

Specifies the path to the converted virtual hard disk file.

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ParentPath<String>

Specifies the parent path for the destination-differencing virtual hard disk file.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Passthru

Specifies that an object is to be passed through to the pipeline representing the converted virtual hard disk.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Path<String>

Specifies the path to the virtual hard disk file to be converted. If a file name or relative path is specified, the path of the converted hard disk path is calculated relative to the current working directory

Aliases

FullName

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue, ByPropertyName)

Accept Wildcard Characters?

false

-VHDType<VhdType>

Specifies the type of the converted virtual hard disk. Allowed values are Fixed, Dynamic, and Differencing. The default is determined by the type of source virtual hard disk.

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.

Examples

Example 1

This example converts a source VHD to a destination VHDX. Because the format is determined by the file extension and the default type is determined by the source virtual hard disk when no type is specified, the destination virtual hard disk will be a VHDX-format disk of the same type as the source virtual hard disk.

PS C:\> Convert-VHD –Path c:\test\testvhd.vhd –DestinationPath c:\test\testvhdx.vhdx

Example 2

This example converts a source differencing disk of VHDX format to a destination differencing disk of VHD format that is connected to an existing parent disk.

PS C:\> Convert-VHD –Path c:\test\child1vhdx.vhdx –DestinationPath c:\test\child1vhd.vhd –VHDType Differencing –ParentPath c:\test\parentvhd.vhd