Convert-SCVirtualDiskDrive

Applies To: System Center 2012 - Virtual Machine Manager

Convert-SCVirtualDiskDrive

Converts an existing virtual hard disk attached to a virtual disk drive object from dynamic to fixed or from fixed to dynamic, or converts a pass-through disk attached to a virtual disk drive object to a virtual hard disk.

Syntax

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

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

Detailed 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, or converts a pass-through disk attached to a virtual disk drive object to a virtual hard disk.

CONVERTING A VIRTUAL HARD DISK FROM DYNAMIC TO FIXED, OR VICE VERSA

----------------------------------------------------------------

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 virtual hard disk file (a .vhd file) on a virtual machine deployed on a Hyper-V host.

A VMware-based virtual hard disk file (a .vmdk file) on a virtual machine that is deployed on an ESX host is fixed in format and therefore cannot be converted to a dynamic format.

A Citrix XenServer-based virtual hard disk file (a .vhd file) on a virtual machine that is deployed on a Citrix XenServer host is also fixed in format and therefore cannot be converted to a dynamic format.

CONVERTING A PASS-THROUGH DISK TO A VIRTUAL HARD DISK

--------------------------------------------------

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. You can use Convert-SCVirtualDiskDrive to convert 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 before you can convert the pass-through disk to a virtual hard disk.

For more information about Convert-SCVirtualDiskDrive, type: "Get-Help Convert-SCVirtualDiskDrive -online".

Parameters

-Dynamic

Specifies that a virtual hard disk can expand dynamically.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FileName<String>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Fixed

Specifies that a virtual hard disk is fixed in size.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobGroup<Guid>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-JobVariable<String>

Specifies that job progress is tracked and stored in the variable named by this parameter.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Path<String>

Specifies the destination path for the operation.

Example formats:

Local path -Path "F:\"

UNC path -Path "\\Library\Templates"

Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"

VMware ESX path "Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"

Citrix XenServer path - Path "Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]"

Wildcards are supported for "Get" cmdlets and when you specify the UNC path:

Example format:

UNC path -Path "\\VMHostServer\MyVMs\*VM*"

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PROTipID<Guid>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsynchronously

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VirtualDiskDrive<VirtualDiskDrive>

Specifies a virtual disk drive object. You can attach either a virtual hard disk (for a virtual machine on any host) or a pass-through disk (for a virtual machine on a Hyper-V host or an ESX host) to a virtual disk drive object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters.

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.

  • VirtualDiskDrive

Examples

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

The first command gets the the virtual machine object named VM01 and stores the 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 passthrough disk.

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

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

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

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

The first command gets the virtual machine object named VM02 and stores the object in $VM. This example assumes that VM02 has three virtual disk drive objects and that the first virtual disk drive is bound to a virtual hard 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 stores them in the $VirtDiskDrive object array.

The last command converts the third pass-through disk ($VirtDiskDrive [2]) to a dynamically expanding virtual hard disk and moves this new virtual hard disk to the destination folder "D:\".

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

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

The first command gets the virtual disk drive object that is attached to virtual machine VM03 and stores the 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.

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

Compress-SCVirtualDiskDrive

Expand-SCVirtualDiskDrive

Get-SCVirtualDiskDrive

New-SCVirtualDiskDrive

Remove-SCVirtualDiskDrive

Set-SCVirtualDiskDrive