Hi Luc,
I want to use this script to apply to all VM's in the Clusters. I modified the call to be:
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