次の方法で共有


Convert-SCVirtualDiskDrive

Convert-SCVirtualDiskDrive

Converts an existing virtual hard disk attached to a virtual disk drive object from dynamic to fixed, 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.

Syntax

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

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

Parameter Set: VHDX
Convert-SCVirtualDiskDrive [-VirtualDiskDrive] <VirtualDiskDrive> -VHDX [-BlockSizeBytes <Int32> ] [-DeleteSource] [-FileName <String> ] [-JobGroup <Guid]> ] [-JobVariable <String> ] [-Path <String> ] [-PROTipID <Guid]> ] [-RunAsynchronously] [-ValidateOnCompletion] [ <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.
-- From VHD to VHDX.
-- A pass-through disk attached to a virtual disk drive object to a virtual hard disk.

To convert a 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.

To convert a VHD to VHDX, 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 from VHD to VHDX on a virtual machine deployed on a Hyper-V host.

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.

Parameters

-BlockSizeBytes<Int32>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DeleteSource

Indicates that the source virtual hard disk is deleted after a successful conversion.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-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 "F:\"

UNC: -Path "\\Library\Templates"

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

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

Citrix XenServer: -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 "\\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

-ValidateOnCompletion

Indicates that the converted virtual hard disk is validated after a successful conversion.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VHDFormatType<VHDFormatType]>

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VHDX

Specifies that a virtual hard disk type is VHDX.

Aliases

none

Required?

true

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 (https://go.microsoft.com/fwlink/p/?LinkID=113216).

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

Example 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 virtual machine object named VM01, and then 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 pass-through disk.

The second command gets the virtual disk drive object on VM01, and then 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"

Example 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 then 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 then 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:\" 

Example 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 then 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-SCVirtualDiskDrive -VM (Get-SCVirtualMachine -Name "VM03")
PS C:\> Convert-SCVirtualDiskDrive -VirtualDiskDrive $VirtDiskDrive -Fixed

Example 4: Convert a dynamic VHD attached to a virtual disk drive object on a virtual machine to fixed VHDX

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

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

Example 5: Convert a differencing VHD attached to a virtual disk drive on a virtual machine to a differencing VHDX

The first command gets the virtual disk drive object that is attached to virtual machine VM04, and then stores the 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. Additionally, this command deletes the source disk.

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

Compress-SCVirtualDiskDrive

Expand-SCVirtualDiskDrive

Get-SCVirtualDiskDrive

New-SCVirtualDiskDrive

Remove-SCVirtualDiskDrive

Set-SCVirtualDiskDrive

Get-SCVirtualMachine