Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 293210

Re: Help with Script for Hot Add CPU/Mem for large number of VMs

$
0
0

Hi Luc,

 

I want to use this script to apply to all VM's in the Clusters. I modified the call to be:

 

 

%{
$vm = Get-VM
Get-Cluster |  Enable-vCpuandMemHotAdd
}

 

I keep getting an error:

 

You cannot call a method on a null-valued expression.

At C:\Scripts\hotadd.ps1:11 char:31

+   $vm.Extensiondata.ReconfigVM <<<< ($vmConfigSpec)

    + CategoryInfo          : InvalidOperation: (ReconfigVM:String) [], Runtim

   eException

    + FullyQualifiedErrorId : InvokeMethodOnNull

 

I've tried powercli versions 5.0 build 435427 and 4.1 U1 build 332441

 

Any advice?

 

The complete script is:

 

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 = Get-VM

Get-Cluster | Enable-vCpuandMemHotAdd


Viewing all articles
Browse latest Browse all 293210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>