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?
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.
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()
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
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()
Hi Macleud,
thanks for your answer 😊
I am not sure what this error is is?
And what does "#text" mean?
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.
PowerShell 5.1
PowerCLI 12.2
vCloud, not sure??
I will try to update first
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()
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