Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated command set #3569

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 95 additions & 44 deletions docset/winserver2022-ps/hyper-v/Convert-VHD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description: Use this topic to help manage Windows and Windows Server technologies with Windows PowerShell.
external help file: Microsoft.HyperV.PowerShell.Cmdlets.dll-Help.xml
Module Name: Hyper-V
ms.date: 12/20/2016
ms.date: 06/21/2023
online version: https://learn.microsoft.com/powershell/module/hyper-v/convert-vhd?view=windowsserver2022-ps&wt.mc_id=ps-gethelp
schema: 2.0.0
title: Convert-VHD
Expand All @@ -16,42 +16,58 @@ Converts the format, version type, and block size of a virtual hard disk file.
## SYNTAX

```
Convert-VHD [-Path] <String> [-DestinationPath] <String> [-VHDType <VhdType>] [-ParentPath <String>]
[-BlockSizeBytes <UInt32>] [-DeleteSource] [-AsJob] [-Passthru] [-CimSession <CimSession[]>]
[-ComputerName <String[]>] [-Credential <PSCredential[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
Convert-VHD [-Path] <String> [-DestinationPath] <String> [-VHDType <VhdType>]
[-ParentPath <String>] [-BlockSizeBytes <UInt32>] [-DeleteSource] [-AsJob]
[-PassThru] [-AddressAbstractionType <VirtualHardDiskPmemAddressAbstractionType>]
[-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.

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

```powershell
Convert-VHD -Path C:\test\testvhd.vhd -DestinationPath C:\test\testvhdx.vhdx
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the PowerShell prompt back as this is an illustrative example. Review your other examples as well as many, if not all, appear to be illustrative and should have this change reverted.

```

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

```powershell
$parameters = @{
DestinationPath = "C:\test\child1vhd.vhd"
VHDType = "Differencing"
ParentPath = "C:\test\parentvhd.vhd"
}
Convert-VHD -Path c:\test\child1vhdx.vhdx @parameters
```

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.
This example converts a source differencing disk of **VHDX** format to a destination differencing
disk of **VHD** format that's connected to an existing parent disk.

## PARAMETERS

### -AsJob

Runs the cmdlet as a background job.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -61,12 +77,13 @@ Accept wildcard characters: False
```

### -BlockSizeBytes

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

```yaml
Type: UInt32
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -76,14 +93,16 @@ 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](https://go.microsoft.com/fwlink/p/?LinkId=227967) or [Get-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227966) cmdlet.
The default is the current session on the local computer.

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](https://go.microsoft.com/fwlink/p/?LinkId=227967)
or [Get-CimSession](https://go.microsoft.com/fwlink/p/?LinkId=227966) cmdlet. The default is the
current session on the local computer.

```yaml
Type: CimSession[]
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -93,15 +112,15 @@ Accept wildcard characters: False
```

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

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.

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -111,6 +130,7 @@ Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Expand All @@ -126,13 +146,14 @@ Accept wildcard characters: False
```

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

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

```yaml
Type: PSCredential[]
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -142,12 +163,13 @@ Accept wildcard characters: False
```

### -DeleteSource

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

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -157,12 +179,13 @@ Accept wildcard characters: False
```

### -DestinationPath

Specifies the path to the converted virtual hard disk file.

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Aliases:

Required: True
Position: 1
Expand All @@ -172,12 +195,13 @@ Accept wildcard characters: False
```

### -ParentPath

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

```yaml
Type: String
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -186,13 +210,15 @@ 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.
### -PassThru

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

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Aliases:

Required: False
Position: Named
Expand All @@ -202,8 +228,10 @@ Accept wildcard characters: False
```

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

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

```yaml
Type: String
Expand All @@ -218,14 +246,14 @@ Accept wildcard characters: False
```

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

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.

```yaml
Type: VhdType
Parameter Sets: (All)
Aliases:
Aliases:
Accepted values: Unknown, Fixed, Dynamic, Differencing

Required: False
Expand All @@ -236,8 +264,8 @@ Accept wildcard characters: False
```

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

Shows what would happen if the cmdlet runs. The cmdlet isn't run.

```yaml
Type: SwitchParameter
Expand All @@ -246,16 +274,22 @@ Aliases: wi

Required: False
Position: Named
Default value: False
Default value: None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-WhatIf is a SwitchParameter which is either $true or $false. Please review your other -WhatIf changes.

Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
-WarningAction, and -WarningVariable. For more information, see
[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### System.String

## OUTPUTS

### Microsoft.Vhd.PowerShell.VirtualHardDisk
Expand All @@ -264,3 +298,20 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable

## RELATED LINKS

[Get-VHD](get-vhd.md)

[Dismount-VHD](dismount-vhd.md)

[Merge-VHD](merge-vhd.md)

[Mount-VHD](mount-vhd.md)

[New-VHD](new-vhd.md)

[Optimize-VHD](optimize-vhd.md)

[Resize-VHD](resize-vhd.md)

[Set-VHD](set-vhd.md)

[Test-VHD](test-vhd.md)
Loading