Share via


Convert-SCVirtualDiskDrive

Converts a virtual hard disk from dynamic to fixed, from fixed to dynamic, from VHD to VHDX, or converts a pass-through disk to a virtual hard disk.

Syntax

Fixed

Convert-SCVirtualDiskDrive
    [-VirtualDiskDrive] <VirtualDiskDrive>
    [-Fixed]
    [-Path <String>]
    [-FileName <String>]
    [-VHDFormatType <VHDFormatType>]
    [-JobGroup <Guid>]
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [<CommonParameters>]

Dynamic

Convert-SCVirtualDiskDrive
    [-VirtualDiskDrive] <VirtualDiskDrive>
    [-Dynamic]
    [-Path <String>]
    [-FileName <String>]
    [-VHDFormatType <VHDFormatType>]
    [-JobGroup <Guid>]
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [<CommonParameters>]

VHDX

Convert-SCVirtualDiskDrive
    [-VirtualDiskDrive] <VirtualDiskDrive>
    [-VHDX]
    [-DeleteSource]
    [-ValidateOnCompletion]
    [-Path <String>]
    [-FileName <String>]
    [-JobGroup <Guid>]
    [-BlockSizeBytes <Int32>]
    [-RunAsynchronously]
    [-PROTipID <Guid>]
    [-JobVariable <String>]
    [<CommonParameters>]

Description

The Convert-SCVirtualDiskDrive cmdlet converts an existing virtual hard disk attached to a virtual disk drive object from dynamic to fixed or from fixed to dynamic, from VHD to VHDX, or converts a pass-through disk attached to a virtual disk drive object to a virtual hard disk.

To convert the virtual hard disk from one format to the other, the virtual machine on which the virtual hard disk is configured must be in a stopped state.

You can only convert the disk format of a Windows-based .vhd file on a virtual machine deployed on a Hyper-V host.

A VMware-based .vmdk file) on a virtual machine that is deployed on an ESX host is fixed in format. You cannot convert it to a dynamic format.

A Citrix XenServer-based .vhd file on a virtual machine that is deployed on a Citrix XenServer host is fixed in format. You cannot convert it to a dynamic format.

You can only convert the disk format of a Windows-based virtual hard disk file from VHD to VHDX on a virtual machine that is deployed on a Hyper-V host. To convert a VHD to VHDX, the virtual machine on which the virtual hard disk is configured must be in a stopped state.

A pass-through disk is a physical hard disk on the host that a virtual machine can use instead of using a virtual hard disk. This cmdlet converts a pass-through disk attached to a virtual disk drive on a virtual machine to a virtual hard disk. The virtual machine must be on a Hyper-V host, and must be in a stopped state.

Examples

Example 1: Convert a pass-through disk on a virtual machine to a virtual hard disk

PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM $VM
PS C:\> Convert-VirtualDiskDrive $VirtDiskDrive -Fixed -Path "C:\VirtualDiskDrives"

The first command gets the virtual machine object named VM01 by using the Get-SCVirtualMachine cmdlet. The command stores that object in the $VM variable. This example assumes that VM01 is currently configured to use a pass-through disk and that the virtual machine has only one pass-through disk.

The second command gets the virtual disk drive object on VM01, and then stores that object in the $VirtDiskDrive variable.

The last command converts the pass-through disk drive stored in $VirtDiskDrive to a fixed virtual hard disk. The command moves the virtual hard disk to the destination folder C:\VirtualDiskDrives.

Example 2: Convert one of several pass-through disks on a virtual disk drive on a virtual machine to a virtual hard disk

PS C:\> $VM = Get-SCVirtualMachine -Name "VM02"
PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM $VM
PS C:\> $VirtDiskDrive[2] | Convert-SCVirtualDiskDrive -Dynamic -Path "D:\"

The first command gets the virtual machine object named VM02, and then stores that object in the $VM variable. This example assumes that VM02 has three virtual disk drive objects and that the first virtual disk drive is bound to a virtual hard disk drive whereas both the second and third virtual disk drives are bound to pass-through disks.

The second command gets all virtual disk drive objects on VM02, and then stores those objects in the $VirtDiskDrive object array.

The last command converts the third pass-through disk, which is the third member of the $VirtDiskDrive array, to a dynamically expanding virtual hard disk. The commandmoves this new virtual hard disk to the destination folder D:.

Example 3: Convert a dynamic VHD attached to a virtual disk drive object on a virtual machine to a fixed format

PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM (Get-SCVirtualMachine -Name "VM03")
PS C:\> Convert-SCVirtualDiskDrive -VirtualDiskDrive $VirtDiskDrive -Fixed

The first command gets the virtual disk drive object that is attached to virtual machine VM03, and then stores that virtual disk drive object in the $VirtDiskDrive variable. This example assumes that the virtual machine has only one virtual disk drive object and that the virtual hard disk attached to the virtual disk drive is a dynamic virtual hard disk.

The second command converts the virtual hard disk stored in $VirtDiskDrive to a fixed disk.

Example 4: Convert a dynamic VHD on a virtual machine to fixed VHDX

PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM (Get-SCVirtualMachine -Name "VM03")
PS C:\> Convert-SCVirtualDiskDrive -VirtualDiskDrive $VirtDiskDrive -VHDX

The first command gets the virtual disk drive object that is attached to virtual machine VM03, and stores that object in the $VirtDiskDrive variable. This example assumes that the virtual machine has only one virtual disk drive object and that the virtual hard disk attached to the virtual disk drive is a dynamic virtual hard disk. This example also assumes that the virtual machine is in a stopped state.

The second command converts the virtual hard disk stored in $VirtDiskDrive to a VHDX disk.

Example 5: Convert a differencing VHD to a differencing VHDX

PS C:\> $VirtDiskDrive = Get-VirtualDiskDrive -VM (Get-SCVirtualMachine -Name "VM04")
PS C:\> Convert-VirtualDiskDrive -VirtualDiskDrive $VirtDiskDrive -VHDX -BlockSizeBytes 1MB -DeleteSource -ValidateOnCompletion

The first command gets the virtual disk drive object that is attached to virtual machine VM04, and then stores that object in the $VirtDiskDrive variable. This example assumes that the virtual machine has only one virtual disk drive object and that the virtual hard disk attached to the virtual disk drive is a dynamic virtual hard disk. This example also assumes that the virtual machine is in a stopped state.

The second command converts the differencing virtual hard disk stored in $VirtDiskDrive to a differencing VHDX disk. This command deletes the source disk.

Parameters

-BlockSizeBytes

Specifies the block size, in bytes, for the virtual hard disk.

Parameter properties

Type:Int32
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

VHDX
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-DeleteSource

Indicates that this cmdlet deletes the source virtual hard disk after a successful conversion.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

VHDX
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Dynamic

Specifies that a virtual hard disk can expand dynamically.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Dynamic
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-FileName

Specifies the file name to use when you rename a virtual hard disk file as you add it to a virtual machine.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Fixed

Indicates that a virtual hard disk is fixed in size. Specifies that a virtual hard disk is fixed in size.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

Fixed
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-JobGroup

Specifies an identifier for a series of commands that run as a set just before the final command that includes the same job group identifier runs.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-JobVariable

Specifies a variable in which job progress is tracked and stored.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Path

Specifies the logical unit number (LUN) for a virtual disk drive object or for a virtual disk drive object on a SCSI bus.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-PROTipID

Specifies the ID of the Performance and Resource Optimization tip (PRO tip) that triggered this action. This parameter lets you audit PRO tips.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ValidateOnCompletion

Indicates that this cmdlet validates the converted virtual hard disk after a successful conversion.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

VHDX
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VHDFormatType

Specifies the hard disk format type. Valid values are:

  • VHD
  • VMDK
  • VHDX

Parameter properties

Type:VHDFormatType
Default value:None
Accepted values:VHD, VMDK, VHDX, VHDS
Supports wildcards:False
DontShow:False

Parameter sets

Fixed
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
Dynamic
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VHDX

Indicates that a virtual hard disk type is VHDX.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

VHDX
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-VirtualDiskDrive

Specifies a virtual disk drive object. You can attach either a virtual hard disk or a pass-through disk to a virtual disk drive object.

Parameter properties

Type:VirtualDiskDrive
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:False
Value from remaining arguments:False

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

VirtualDiskDrive

This cmdlet returns a VirtualDiskDrive object.