< Back

Set-HardDisk

Sun Jan 19, 2020 7:08 pm

NAME Set-HardDisk



SYNOPSIS

This cmdlet modifies the properties of the specified virtual hard disk.





SYNTAX

Set-HardDisk [-HardDisk] <HardDisk[]> [[-CapacityKB] <Int64>] [[-Persistence] <String>] [[-Datastore] <Datastore>]

[-CapacityGB <Decimal>] [-Controller <ScsiController>] [-Server <VIServer[]>] [-StorageFormat

<VirtualDiskStorageFormat>] [-Confirm] [-WhatIf] [<CommonParameters>]



Set-HardDisk [-HardDisk] <HardDisk[]> [[-CapacityKB] <Int64>] [[-Persistence] <String>] [[-Datastore] <Datastore>]

[-CapacityGB <Decimal>] [-Controller <ScsiController>] [-GuestCredential <PSCredential>] [-GuestPassword

<SecureString>] [-GuestUser <String>] [-HelperVM <VirtualMachine>] [-HostCredential <PSCredential>] [-HostPassword

<SecureString>] [-HostUser <String>] [-Partition <String>] [-ResizeGuestPartition] [-Server <VIServer[]>]

[-StorageFormat <VirtualDiskStorageFormat>] [-ToolsWaitSecs <Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]



Set-HardDisk [-HardDisk] <HardDisk[]> [-Inflate] [-Confirm] [-WhatIf] [<CommonParameters>]



Set-HardDisk [-HardDisk] <HardDisk[]> [-ZeroOut] [-Confirm] [-WhatIf] [<CommonParameters>]



Set-HardDisk [-HardDisk] <HardDisk[]> [-Confirm] [-WhatIf] -DisableEncryption [-RunAsync] [<CommonParameters>]



Set-HardDisk [-HardDisk] <HardDisk[]> [-Confirm] [-WhatIf] [-KmsCluster <KmsCluster>] [-RunAsync] [-StoragePolicy

<StoragePolicy>] [<CommonParameters>]





DESCRIPTION

This cmdlet modifies the properties of the specified virtual hard disk. You can encrypt the specified virtual hard

disk or decrypt the specified virtual hard disk. You can also 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 CapacityGB 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. For a list of supported operating

systems, see the VMware PowerCLI User's Guide.





PARAMETERS

-CapacityGB <Decimal>

Specifies the updated capacity of the virtual disk in gigabytes (GB). If you are connected to a vCenter Server

2.0 or ESX 3.0, the size of the disk cannot be changed and the CapacityGB parameter is discarded. If you are

connected to a vCenter Server 2.5 or ESX 3.5, the size of the disk can only be increased and the CapacityGB

parameter is discarded if its value is less than the current disk size.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-CapacityKB <Int64>

This parameter is obsolete. Use CapacityGB instead. Specifies the updated capacity of the virtual disk in

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



Required? false

Position? 2

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Controller <ScsiController>

Specifies a SCSI controller to which you want to attach the hard disk.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Datastore <Datastore>

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



Required? false

Position? 4

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-GuestCredential <PSCredential>

Specifies the PSCredential object that contains the credentials you want to use for authenticating with the

guest operating system.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-GuestPassword <SecureString>

Specifies the password you want to use for authenticating with the guest operating system.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-GuestUser <String>

Specifies the username you want to use for authenticating with the guest operating system.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-HardDisk <HardDisk[]>

Specifies the virtual hard disk you want to configure.



Required? true

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-HelperVM <VirtualMachine>

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



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-HostCredential <PSCredential>

Specifies the PSCredential object that contains the credentials you want to use for authenticating with the

host.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-HostPassword <SecureString>

Specifies the password you want to use for authenticating with the host.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-HostUser <String>

Specifies the username you want to use for authenticating with the host.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Inflate [<SwitchParameter>]

Indicates that you want to inflate the hard disk.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Partition <String>

Specifies the partitions you want to resize. On Windows, you can specify which partition you want to resize by

using the Partition parameter. If you do not 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 VMware PowerCLI installation. You can modify these scripts or add new ones to

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



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Persistence <String>

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



Required? false

Position? 3

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ResizeGuestPartition [<SwitchParameter>]

Note: This functionality is deprecated and is not functional on the currently supported guest operating

systems. Resizing guest disks works only on Windows XP Service Pack 3 and Red Hat Enterprise Linux 5.



Indicates that you want to resize the guest partition of the disk. To use this feature, VMware Tools must be

running on the virtual machine. On Windows, you can specify which partition you want to resize by using 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 VMware PowerCLI installation. You can modify these scripts or add new ones to

support 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_<OS_Identifier>



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



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Server <VIServer[]>

Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is given to this

parameter, the command runs on the default servers. For more information about default servers, see the

description of Connect-VIServer.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-StorageFormat <VirtualDiskStorageFormat>

Specifies 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. This parameter accepts Thin,

Thick, and EagerZeroedThick values.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ToolsWaitSecs <Int32>

Specifies the time in seconds to wait for a response from 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



-ZeroOut [<SwitchParameter>]

Specifies that you want to fill the hard disk with zeros. This parameter is supported only if you are directly

connected to an ESX/ESXi host.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

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



-WhatIf [<SwitchParameter>]

Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are

modified.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-DisableEncryption [<SwitchParameter>]

Indicates that the cmdlet decrypts the specified hard disk.



Required? true

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-KmsCluster <KmsCluster>

Specifies the KmsCluster that you use to generate a key to encrypt the specified hard disk. If StoragePolicy

is not specified then the default encryption storage policy "VM Encryption Policy" is used.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-RunAsync [<SwitchParameter>]

Indicates that the command returns immediately without waiting for the task to complete. In this mode, the

output of the cmdlet is a Task object. For more information about the RunAsync parameter run "help

About_RunAsync" in the VMware PowerCLI console.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-StoragePolicy <StoragePolicy>

Specifies the StoragePolicy to be attached to the specified hard disk. If the storage policy is an encryption

policy, the hard disk will be encrypted.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

Zero or more modified HardDisk objectsHardDisk







NOTES





Set-HardDisk cannot inflate a hard disk that has already been inflated. Non-persistent and undoable disks are

not supported. Migrating a hard disk attached to a virtual machine to a different datastore is supported only

on vCenter Server systems. Encrypt a hard disk needs to meet several requires: - The VM Home of its parent VM

has been encrypted already;



- Its parent VM is powered off;



- The hard disk has no snapshot;



- The hard disk is not multiple shared or digest enabled;



-------------------------- 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 -CapacityGB $extendedCapacity -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.

-------------------------- Example 4 --------------------------



$policy = Get-SpbmStoragePolicy | select -first 1

Set-HardDisk -HardDisk $harddisk -StoragePolicy $policy



Attaches the StoragePolicy $policy to the specified hard disk. If the $policy is an encryption policy, the

specified hard disk will be encrypted. If the $policy is a non-encryption policy, the specified hard disk will be

decrypted (if it is encrypted before this cmdlet) and attached with the new policy.

-------------------------- Example 5 --------------------------



Set-HardDisk -HardDisk $harddisk -DisableEncryption



Decrypt the specified hard disk.



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... dDisk.html

Copy-HardDisk

Get-HardDisk

New-HardDisk

Remove-HardDisk

Move-HardDisk