Expand-SCVirtualDiskDrive

Expands a virtual hard disk attached to a virtual disk drive object.

Syntax

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

Description

The Expand-SCVirtualDiskDrive cmdlet expands a virtual hard disk attached to a virtual disk drive object in order to increase the total capacity of the virtual hard disk. The virtual machine must be deployed on a host managed by Virtual Machine Manager (VMM) and must be in a stopped state before you can expand the virtual hard disk.

This cmdlet expands a Windows-based.vhd or .vhdx file attached to a virtual disk drive object on a virtual machine deployed on a Hyper-V host. You can also use this cmdlet to expand a VMware-based a .vmdk file on a virtual machine deployed on an ESX host. You cannot use this cmdlet to expand a virtual hard disk on a virtual machine deployed on a Citrix XenServer host.

Examples

Example 1: Expand a virtual hard disk

PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> $VirtDiskDrive = Get-SCVirtualDiskDrive -VM $VM | Where-Object {$_.Bus -Eq 0 -And $_.Lun -Eq 0}
PS C:\> Expand-SCVirtualDiskDrive -VirtualDiskDrive $VirtDiskDrive -VirtualHardDiskSizeGB 40

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.

The second command gets the virtual disk drive object located on the first controller ($.Bus -Eq 0) and first slot of that controller ($.Lun -Eq 0) of VM01, and stores that object in the $VirtDiskDrive variable.

The last command expands the size of the virtual hard disk attached to the virtual disk drive to 40 GB.

Required Parameters

-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
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-VirtualHardDiskSizeGB

Specifies the size, in gigabytes (GB), to which a dynamically expanding virtual hard disk expands.

Type:Int32
Aliases:Size
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Optional 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
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
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
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
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
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
Accept pipeline input:False
Accept wildcard characters:False

Outputs

VirtualHardDisk

This cmdlet returns a VirtualHardDisk object.

Notes

  • This cmdlet requires a VMM virtual disk drive object, which can be retrieved by using the Get-SCVirtualDiskDrive cmdlet.