VMware Cloud Community
RoyalFlash
Enthusiast
Enthusiast
Jump to solution

How to increase Disk Size in vCloud Director via PowerCLI?

Hi,

I just wanted to increase the hard disk size of the VMs in vCloud Director via PowerCLI.

All VMs have only one disk with 200GB size, which should be increased to 250GB.

I tried it with Powered On and Powered Off VMs.

 

 

vCloud is updating "some" data. A task "Updated Virtual Machine..." is running below in "Recent Tasks", but Disk Size remains the same.

Nothing is changing.

 

 

$vm = Get-CIVM -Org MyOrg -Name MyVM

$vm.ExtensionData.Section[0].Item[2].VirtualQuantity.Value = 250000

$vm.ExtensionData.Section[0].UpdateServerData()

 

 

 

What is wrong?

0 Kudos
3 Solutions

Accepted Solutions
Macleud
Enthusiast
Enthusiast
Jump to solution

What version of Powershell and PowerCli do you have?

It works for me on Windows and MacOS.
But I have a Powershell version 7.2.0 and PowerCli 12.5.
Checked on vCloud 10.0 and 10.2.

View solution in original post

0 Kudos
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

Try this.

 

$NewSizeGB= 250
$VmView = Get-Civm -name "NameVM" -Org "MyOrg" | Get-CIView
[string]$DiskRoot = $NewSizeGB * 1kb
$VmHardwareSection = $VmView.Section | Where-Object { $_ -is [VMware.VimAutomation.Cloud.Views.OvfVirtualHardwareSection] }
$SectionDisk = $VmHardwareSection.item | Where-Object {$_.Description.Value -eq "Hard disk" }
$ResizeDisk =  $SectionDisk[0].HostResource.AnyAttr | Where-Object {$_."#text" -eq $($SectionDisk[0].VirtualQuantity.value /1mb) }
$ResizeDisk."#text" = $DiskRoot
$VmHardwareSection.UpdateServerData()

 

View solution in original post

0 Kudos
RoyalFlash
Enthusiast
Enthusiast
Jump to solution

GREAT!!

Working, thank you very much Macleud !!

Best support here in this community ! 

Appreciate it very much 😀

 

Solution:

PowerShell 5.1 update to 7.2 (ISE replaced with Visual Studio Code)

PowerCLI 12.2 update to 12.7

vCloud Director is currently on version 10.3.3.19610595

View solution in original post

0 Kudos
6 Replies
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

The VirtualQuantity.Value property cannot be changed.
To resize disk, you need to change the HostResource.AnyAttr property.

You can do it like this.

 

 

$NewSizeGB= 250
$VmView = Get-Civm -name "NameVM" -Org "MyOrg" | Get-CIView
$DiskRoot = [int]$NewSizeGB * 1kb
$VmHardwareSection = $VmView.Section | Where-Object { $_ -is [VMware.VimAutomation.Cloud.Views.OvfVirtualHardwareSection] }
$SectionDisk = $VmHardwareSection.item | Where-Object {$_.Description.Value -eq "Hard disk" }
$ResizeDisk =  $SectionDisk[0].HostResource.AnyAttr | Where-Object {$_."#text" -eq $($SectionDisk[0].VirtualQuantity.value /1mb) }
$ResizeDisk."#text" = $DiskRoot
$VmHardwareSection.UpdateServerData()

 

 

 

 

0 Kudos
RoyalFlash
Enthusiast
Enthusiast
Jump to solution

Hi Macleud,

thanks for your answer 😊

I am not sure what this error is is?

And what does "#text" mean?

RoyalFlash_0-1661445932216.png

 

0 Kudos
Macleud
Enthusiast
Enthusiast
Jump to solution

What version of Powershell and PowerCli do you have?

It works for me on Windows and MacOS.
But I have a Powershell version 7.2.0 and PowerCli 12.5.
Checked on vCloud 10.0 and 10.2.

0 Kudos
RoyalFlash
Enthusiast
Enthusiast
Jump to solution

PowerShell 5.1

PowerCLI 12.2

vCloud, not sure??

I will try to update first

0 Kudos
Macleud
Enthusiast
Enthusiast
Jump to solution

Hi.

Try this.

 

$NewSizeGB= 250
$VmView = Get-Civm -name "NameVM" -Org "MyOrg" | Get-CIView
[string]$DiskRoot = $NewSizeGB * 1kb
$VmHardwareSection = $VmView.Section | Where-Object { $_ -is [VMware.VimAutomation.Cloud.Views.OvfVirtualHardwareSection] }
$SectionDisk = $VmHardwareSection.item | Where-Object {$_.Description.Value -eq "Hard disk" }
$ResizeDisk =  $SectionDisk[0].HostResource.AnyAttr | Where-Object {$_."#text" -eq $($SectionDisk[0].VirtualQuantity.value /1mb) }
$ResizeDisk."#text" = $DiskRoot
$VmHardwareSection.UpdateServerData()

 

0 Kudos
RoyalFlash
Enthusiast
Enthusiast
Jump to solution

GREAT!!

Working, thank you very much Macleud !!

Best support here in this community ! 

Appreciate it very much 😀

 

Solution:

PowerShell 5.1 update to 7.2 (ISE replaced with Visual Studio Code)

PowerCLI 12.2 update to 12.7

vCloud Director is currently on version 10.3.3.19610595

0 Kudos