Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Convert-VHD
- Module:
- Hyper-V Module
Converts the format, version type, and block size of a virtual hard disk file.
Syntax
Default (Default)
Convert-VHD
[-Path] <String>
[-DestinationPath] <String>
[-VHDType <VhdType>]
[-ParentPath <String>]
[-BlockSizeBytes <UInt32>]
[-DeleteSource]
[-AsJob]
[-Passthru]
[-CimSession <CimSession[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential[]>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
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 name 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.
Examples
Example 1
PS C:\> Convert-VHD -Path c:\test\testvhd.vhd -DestinationPath c:\test\testvhdx.vhdx
This example converts a source VHD to a destination VHDX. Because the format is determined by the file name 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.
Example 2
PS C:\> Convert-VHD -Path c:\test\child1vhdx.vhdx -DestinationPath c:\test\child1vhd.vhd -VHDType Differencing -ParentPath c:\test\parentvhd.vhd
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.
Parameters
-AsJob
Runs the cmdlet as a background job.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-BlockSizeBytes
Specifies the block size, in bytes, of the virtual hard disk after conversion.
Parameter properties
| Type: | UInt32 |
| 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
-ComputerName
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.
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
-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
-DeleteSource
Specifies that the source virtual hard disk is to be deleted after the conversion.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DestinationPath
Specifies the path to the converted virtual hard disk file.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ParentPath
Specifies the parent path for the destination-differencing virtual hard disk file.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Passthru
Specifies that an object is to be passed through to the pipeline representing the converted virtual hard disk.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Path
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
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | FullName |
Parameter sets
-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.
Parameter properties
| Type: | VhdType |
| Default value: | None |
| Accepted values: | Unknown, Fixed, Dynamic, Differencing |
| 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.
Outputs
Microsoft.Vhd.PowerShell.VirtualHardDisk
Feedback
Was this page helpful?
