I am trying to modify the memory and CPU allocation for a vCloud Director vApp VM. The vApp is deployed, but stopped. I have tried various combinations of the PowerCLI commandlets, but with no success. My latest attempt, which looked promising, was this...
Get-CIVapp -Name 'VMName' | Get-CIVM | Get-VM | Set-VM -MemoryGB 2 -NumCPU 2
Has anyone found success in doing this?
Thanks
Paul
I hope this woulf solve you problem:
// Get-CIVM
$vm = Get-CIVM -Org '<org-name>' -Name '<vm-name>'
// Modify VM ExtensionData as required
$vm.ExtensionData.Section[0].Item[6].VirtualQuantity.Value = <vCPU-value>
Section[0] is "VMware.VimAutomation.Cloud.Views.OvfVirtualHardwareSection"
Item is "VMware.VimAutomation.Cloud.Views.OvfRASD"
Change VirtualQuantity value as required.
// Finally Update Server Data
$vm.ExtensionData.Section[0].UpdateServerData()
Thanks.
Although this was along time ago the full solution is
"$vm = Get-CIVM -Org $Org -Name $VMName
for($i = 0; $i -le $vm.ExtensionData.Section[0].Item.Length; $i++)
{
if($vm.ExtensionData.Section[0].Item[$i].Description.Value -eq "Memory Size")
{
$vm.ExtensionData.Section[0].Item[$i].VirtualQuantity.Value = $RAMGB
}
elseif ($vm.ExtensionData.Section[0].Item[$i].Description.Value -eq "Number of Virtual CPUs") {
$vm.ExtensionData.Section[0].Item[$i].VirtualQuantity.Value = $NUMCPU
}
}
$vm.ExtensionData.Section[0].UpdateServerData() "
Where
@Org is the vCloud Org your VM belongs to
@RAMGB is the size of the RAM you want in terms of GB
@NUMCPU is the size of the CPU in terms of #
You need to browse for the properties dynamically as they are not always at a fixed index in the Item property.