Skip to content

Commit

Permalink
Updated command set
Browse files Browse the repository at this point in the history
  • Loading branch information
Xelu86 committed Jul 26, 2023
1 parent cc0983d commit e5717df
Show file tree
Hide file tree
Showing 10 changed files with 838 additions and 428 deletions.
124 changes: 82 additions & 42 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 @@ -17,41 +17,55 @@ Converts the format, version type, and block size of a virtual hard disk file.

```
Convert-VHD [-Path] <String> [-DestinationPath] <String> [-VHDType <VhdType>] [-ParentPath <String>]
[-BlockSizeBytes <UInt32>] [-DeleteSource] [-AsJob] [-Passthru] [-CimSession <CimSession[]>]
[-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
```

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 +75,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 +91,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 +110,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 +128,7 @@ Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
```yaml
Expand All @@ -126,13 +144,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 +161,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 +177,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 +193,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 +208,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 +226,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 +244,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 +262,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 +272,22 @@ Aliases: wi

Required: False
Position: Named
Default value: False
Default value: None
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 +296,11 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## RELATED LINKS
- [Get-VHD](get-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

0 comments on commit e5717df

Please sign in to comment.