Compress-SCVirtualDiskDrive

Compresses a dynamically expanding virtual hard.

Syntax

Compress-SCVirtualDiskDrive
        [-VirtualDiskDrive] <VirtualDiskDrive>
        [-JobGroup <Guid>]
        [-RunAsynchronously]
        [-PROTipID <Guid>]
        [-JobVariable <String>]
        [-OnBehalfOfUser <String>]
        [-OnBehalfOfUserRole <UserRole>]
        [<CommonParameters>]

Description

The Compress-SCVirtualDiskDrive cmdlet compresses a dynamically expanding virtual hard disk attached to a virtual disk drive object to reduce the size of the virtual hard disk. The virtual machine must be stopped before you can compress the virtual hard disk.

This cmdlet compresses a Windows-based virtual hard disk file attached to a virtual disk drive object on a virtual machine that is deployed on a Hyper-V host. Virtual hard disks are .vhd or .vhdx files.

A VMware-based.vmdk file on a virtual machine deployed on an ESX Server 3.0 or 3.5 host is not dynamic. You cannot compress a fixed virtual hard disk.

A Citrix XenServer-based.vhd file on a virtual machine deployed on a XenServer host is not dynamic. You cannot compress a fixed disk.

Examples

Example 1: Compress a virtual hard disk on a virtual machine deployed on a host

PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM (Get-SCVirtualMachine -Name "VM01")
PS C:\> Compress-SCVirtualDiskDrive -VirtualDiskDrive $VirtDiskDrive

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

The second command compresses the dynamically expanding virtual hard disk that is attached to the virtual disk drive on VM01.

Parameters

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

Type:Guid
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-JobVariable

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

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OnBehalfOfUser

Specifies a user name. This cmdlet operates on behalf of the user that this parameter specifies.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-OnBehalfOfUserRole

Specifies a user role. Specify this parameter and the OnBehalfOfUser parameter to remove permissions from a user role that belongs to an on behalf of user. To obtain a user role object, use the Get-SCUserRole cmdlet.

Type:UserRole
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:Guid
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RunAsynchronously

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

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters: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.

Type:VirtualDiskDrive
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

Outputs

VirtualDiskDrive

This cmdlet returns a VirtualDiskDrive object.

Notes

  • This cmdlet requires a VMM virtual disk drive object that is currently associated with a virtual machine deployed on a host, which can be retrieved by using the Get-SCVirtualDiskDrive cmdlet.