VMware Cloud Community
goce74
Contributor
Contributor

how to enable "Memory hot add" on a vshpere VM

Hello

I am trying to work out how can I enable "Memory hot add" via powershell to a Vcloud environment VM.

I am trying to look at the following extensiondata but I just can't work it out.

$vm = Get-CIVM -Name $server1

$vm.ExtensionData. ????????

I have found code that is for vshere but not vcloud.

Any help ?

Tags (1)
0 Kudos
3 Replies
LucD
Leadership
Leadership

Have a look at Enable VM Hot-Add CPU/Memory on reboot


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
goce74
Contributor
Contributor

Hello,

I had to change the script cause we are on VCloud

Function Enable-vCpuAndMemHotAdd($vm){

  $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

  $extra1 = New-Object VMware.Vim.optionvalue

  $extra1.Key="mem.hotadd"

  $extra1.Value="true"

  $vmConfigSpec.extraconfig += $extra1

  $extra2 = New-Object VMware.Vim.optionvalue

  $extra2.Key="vcpu.hotadd"

  $extra2.Value="true"

  $vmConfigSpec.extraconfig += $extra2

  #$vm.Extensiondata.ReconfigVM($vmConfigSpec)

  $vm.Extensiondata.ReconfigureVm_task($vmConfigSpec)

}

Connect-CIServer -Server $vcd02 -org $orgArp -Credential $IAASRH

Get-Content  "c:\temp\listofvms.txt" | %{

   $vm = Get-CIVM -Name $_

   Enable-vCpuAndMemHotAdd $vm 

}

When I run it I get the following error

Enable-vCpuAndMemHotAdd($vm)

Cannot find an overload for "ReconfigureVm_Task" and the argument count: "1".

At line:22 char:3

+   $vm.Extensiondata.ReconfigureVm_task($vmConfigSpec)

+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodException

    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

0 Kudos
LucD
Leadership
Leadership

0 Kudos