VMware Cloud Community
paulrg
Contributor
Contributor

set vCloud Director vApp VM memory and hardware with PowerCLI

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

Tags (4)
Reply
0 Kudos
2 Replies
jitrocs
Contributor
Contributor

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.

Reply
0 Kudos
xucito
Contributor
Contributor

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.

Reply
0 Kudos