powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Set-HardDisk



NAME
Set-HardDisk

SYNOPSIS
Changes the properties of the specified virtual hard disk.

SYNTAX
Set-HardDisk [-HardDisk] [[-CapacityKB] ] [[-Persistence] ] [[-Datastore] ]
[-StorageFormat ] [-Controller ] [-Server ] [-WhatIf] [-Confi
rm] []

Set-HardDisk [-HardDisk] [[-CapacityKB] ] [[-Persistence] ] [[-Datastore] ]
[-StorageFormat ] [-Controller ] [-HostCredential ] [-HostU
ser ] [-HostPassword ] [-GuestCredential ] [-GuestUser ] [-GuestPasswor
d ] [-ToolsWaitSecs ] [-HelperVM ] [-Partition ] [-ResizeGuestPartitio
n] [-WhatIf] [-Confirm] []

Set-HardDisk [-HardDisk] [-Inflate] [-WhatIf] [-Confirm] []

Set-HardDisk [-HardDisk] [-ZeroOut] [-WhatIf] [-Confirm] []


DESCRIPTION
Changes the properties of the specified virtual hard disk. You can change the size and the persistence type, and in
flate or expand the specified virtual hard disk. Do not use the Inflate parameter at the same time with the Persist
ence 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 disk
s using a helper virtual machine, the disks are resized one by one causing the helper machine to power on and off f
or each virtual machine and this might slow the cmdlet performance. The guest disk resizing functionality supports
only Windows XP 32 SP3, Windows Server 2003 32bit SP2, Windows Server 2003 64bit SP2, Windows 7 64 bit, Windows Ser
ver 2008 R2 64bit and Redhat Enterprise 5 guest operating systems. Please consider the Set-HardDisk feature to be e
xperimental as it might be changed or removed in a future release.


PARAMETERS
-HardDisk
Specify the virtual hard disk you want to configure.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-CapacityKB
Specify 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 connect
ed to a vCenter Server 2.5 or ESX 3.5 server, the size of the disk can only be increased and the CapacityKB par
ameter is discarded if its value is less than the current disk size.

Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Persistence
Specify the disk persistence mode. The valid values are Persistent, NonPersistent, IndependentPersistent, Indep
endentNonPersistent, and Undoable. This parameter is supported only when the disk type is rawVirtual or flat.
The NonPersistent and Undoable values are deprecated and scheduled for removal. Their usage is not recommended
because they do not work with snapshots and are not supported on ESX 3.5 and higher.

Required? false
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Datastore
Specify the datastore to which you want to move the specified hard disk. Moving a hard disk attached to a virtu
al machine to a different datastore is only supported on vCenter Server.

Required? false
Position? 4
Default value
Accept pipeline input? false
Accept wildcard characters? true

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

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Controller
Specify a SCSI controller to which you want to attach the hard disk.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modi
fied.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value $true
Accept pipeline input? false
Accept wildcard characters? false

-HostCredential
Specify the PSCredential object that contains the credentials you want to use in authentication with the host.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-HostUser
Specify a username you want to use in authentication with the host.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-HostPassword
Specify a password you want to use in authentication with the host.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestCredential
Specify the PSCredential object that contains the credentials you want to use in authentication with the guest
operating system.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestUser
Specify a username you want to use in authentication with the guest operating system.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-GuestPassword
Specify a password you want to use in authentication with the guest operating system.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value $null
Accept pipeline input? false
Accept wildcard characters? false

-HelperVM
Specify 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 m
ust be powered off before expanding the disk. When you resize more than one disks using a helper virtual machin
e, the disks are resized one by one causing the helper machine to power on and off for each virtual machine, an
d this might slow down the cmdlet performance.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Partition
Specify the partitions you want to resize. On Windows, you can specify which partition you want to resize by us
ing the Partition parameter. If you don't specify a partition, the last partition of the disk is resized.
On Linux, only the last partition can be expanded.

Resizing guest partitions is supported only for Windows OS and for ext3 partitions on RHEL 5. It is achieved by
scripts, provided with the vSphere PowerCLI installation. You can modify these scripts or add new ones to supp
ort operating systems different than Windows and RHEL 5, and more specific disk resizing scenarios. The scripts
are located in the "Scripts" folder in the PowerCLI installation directory and their names have the following
format:

GuestDiskExpansion_

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.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ResizeGuestPartition
Indicate that you want to resize the guest partition of the disk. To use this feature, VMware Tools must be run
ning on the virtual machine.
On Windows, you can specify which partition you want to resize by using the Partition parameter. If you don't s
pecify a partition, the last partition of the disk is resized.
On Linux, only the last partition can be expanded.

Resizing guest partitions is supported only for Windows OS and for ext3 partitions on RHEL 5. It is achieved by
scripts, provided with the vSphere PowerCLI installation. You can modify these scripts or add new ones to supp
ort operating systems different than Windows and RHEL 5, and more specific disk resizing scenarios. The scripts
are located in the "Scripts" folder in the PowerCLI installation directory and their names have the following
format:

GuestDiskExpansion_

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

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Inflate
Indicate that you want to inflate the hard disk.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ZeroOut
Specify that you want to fill the hard disk with zeros. This parameter is supported only if you are directly co
nnected to an ESX host. The ZeroOut functionality is experimental.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
HardDisk


NOTES


If you are connected to an ESX 3.0 host, the size of the disk cannot be changed 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 Capacit
yKB 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. Set-HardDisk cannot inflate a hard
disk that has already been inflated.
On ESX versions higher than 3.0, non-persistent and undoable disks are not supported.
Guest partitions resizing is supported only on ESX 3.5 and later, and works only in 32-bit mode.
Migrating a hard disk attached to a virtual machine to a different datastore is supported only on vCenter Serve
r.

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

C:\PS>Get-HardDisk -VM $vm | Set-HardDisk -Persistence "IndependentNonPersistent"


Changes the persistence of a hard disk to IndependentNonPersistent.





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

C:\PS>Set-HardDisk -HardDisk $harddisk -CapacityKB $extendedCapacity -HostCredential $hostCred -GuestCredential $gu
estCred


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





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

C:\PS>Set-HardDisk -HardDisk $harddisk -Datastore $datastore


Moves the hard disk to the specified datastore.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Set-HardDisk.html
Copy-HardDisk
Get-HardDisk
New-HardDisk
Remove-HardDisk