vSphere PowerCLI Cmdlets Reference

Set-HardDisk

Synopsis

Changes the properties of the specified virtual hard disk.

Syntax

Set-HardDisk [-HardDisk] <HardDisk[]> [[-CapacityKB] <Int64>] [[-Persistence] <String>] [[-Datastore] <Datastore>] [-StorageFormat <VirtualDiskStorageFormat>] [-HostCredential <PSCredential>] [-HostUser <String>] [-HostPassword <SecureString>] [-GuestCredential <PSCredential>] [-GuestUser <String>] [-GuestPassword <SecureString>] [-ToolsWaitSecs <Int32>] [-HelperVM <VirtualMachine>] [-Partition <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-HardDisk [-HardDisk] <HardDisk[]> [-Inflate] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Copy-HardDisk
Get-HardDisk
New-HardDisk
Remove-HardDisk

Detailed Description

Changes the properties of the specified virtual hard disk. You can change the size and the persistence type, and inflate or expand the specified virtual hard disk. Do not use the Inflate parameter at the same time with the Persistence and CapacityKB parameters. If a helper virtual machine is used, all virtual machines associated with the disk and the helper virtual machine should be powered off before expanding the disk. When you resize more than one disks using a helper virtual machine, the disks are resized one by one causing the helper machine to power on and off for each virtual machine and this might slow the cmdlet performance. Consider that guest disk resizing functionality is experimental.

Parameters

NameDescriptionRequired?Pipeline InputDefault Value
HardDiskSpecify the virtual hard disk you want to configure.truetrue (ByValue)
CapacityKBSpecify the updated capacity of the virtual disk (in KB). if you are connected to a vCenter Server 2.0 or ESX 3.0 server, the size of the disk cannot be changed and the CapacityKB parameter is discarded. If you are connected to a vCenter Server 2.5 or ESX 3.5 server, the size of the disk can only be increased and the CapacityKB parameter is discarded if its value is less than the current disk size.falsefalse
PersistenceSpecify the disk persistence mode. The valid values are Persistent, NonPersistent, IndependentPersistent, IndependentNonPersistent, and Undoable. This parameter is supported only when the disk type is rawVirtual or flat. The NonPersistent and Undoable persistence policies are deprecated and will be discontinued in a future release. Their usage is not recommended because they do not work with snapshots and are not supported on ESX 3.5 and higher.falsefalse
DatastoreSpecify the datastore to which you want to move the specified hard disk. Moving a hard disk attached to a virtual machine to a different datastore is only supported on vCenter Server.falsefalse
StorageFormatSpecify the storage format of the relocated hard disk. This parameter is applicable only when moving a virtual machine disk to a different datastore, using the -Datastore parameter. The valid values are Thin and Thick.falsefalse
HostCredentialSpecify the PSCredential object that contains the credentials you want to use in authentication with the host.falsefalse
HostUserSpecify a username you want to use in authentication with the host.falsefalse
HostPasswordSpecify a password you want to use in authentication with the host.falsefalse
GuestCredentialSpecify the PSCredential object that contains the credentials you want to use in authentication with the guest operating system.falsefalse
GuestUserSpecify a username you want to use in authentication with the guest operating system.falsefalse
GuestPasswordSpecify a password you want to use in authentication with the guest operating system.falsefalse
ToolsWaitSecsSpecify the time in seconds to wait for a response from the VMware Tools. If a non-positive value is provided, the system waits infinitely long time.falsefalse$null
HelperVMSpecify a helper virtual machine you want to use when expanding a Windows virtual machine system disk.
LVM (logical volume manager) for Linux is not supported and Linux guest system disks cannot be expanded. When a helper virtual machine is used, all virtual machines associated with the disk and the helper virtual machine must be powered off before expanding the disk. When you resize more than one disks using a helper virtual machine, the disks are resized one by one causing the helper machine to power on and off for each virtual machine, and this might slow down the cmdlet performance.
falsefalse
PartitionSpecify the partitions you want to expand. On Windows, if you want to expand not the last partition of a multi-partitioned disk, the disk must be dynamic. On Linux, if the disk you want to expand is multi-partitioned, only the last partition can be expanded. Guest disk expansion is achieved by scripts, provided with the vSphere PowerCLI installation. You can modify these scripts or add new ones to support more specific disk expansion scenarios. They are located in the "Scripts" folder in the PowerCLI installation directory and their names have the following format:

GuestDiskExpansion_<OS_Identifier>

<OS_Identifier> is the guest family or the guest ID (as returned by Get-VMGuest).

If no partition is specified, the last partition of the hard disk is resized.
falsefalse
WhatIfIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse
ConfirmIf the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.falsefalse$true
InflateIndicate that you want to inflate the hard disk.falsefalse

Return Type

HardDisk

Notes

If you are connected to an ESX 3.0 host, the size of the disk cannot be cha nged and the CapacityKB parameter is discarded. If you are connected to an ESX 3.5 host, the size of the disk can only be increased and the CapacityKB parameter is discarded if its value is less than the current disk size. The Inflate parameter is supported only when connected to ESX 3.5 or later. On ESX versions higher than 3.0, non-persistent and undoable disks are not supported. Guest resizing is supported only on ESX 3.5 and later. Migrating a hard disk attached to a virtual machine to a different datastor e is supported only on vCenter Server.

Examples

-------------- Example 1 --------------

Get-HardDisk -VM $vm | Set-HardDisk -Persistence "IndependentNonPersistent"

Changes the persistence of a hard disk to IndependentNonPersistent.

-------------- Example 2 --------------

Set-HardDisk -HardDisk $harddisk -CapacityKB $extendedCapacity -HostCredential $hostCred -GuestCredential $guestCred

Extends a hard disk with the specified capacity. The command also extends the disk on the guest OS.

-------------- Example 3 --------------

Set-HardDisk -HardDisk $harddisk -Datastore $datastore

Moves the hard disk to the specified datastore.


Copyright © 1998 - 2010 VMware, Inc. All rights reserved.