Try this. I took the hotadd function from here:
http://ict-freak.nl/2009/10/05/powercli-enabledisable-the-vm-hot-add-features/
I tested against 1 VM and it works ok. it will loop and power all VM's off in parallel, then it will modify them all. THen power them all on in parallel. If you don't want parallel you can modify it.
I would test in your lab or against 1-2 non prod VM's first.
Same CSV colum
VMNAME,MEM,CPU
FunctionEnable-MemHotAdd($vm){
$vmview=Get-vm$vm | Get-View
$vmConfigSpec=New-ObjectVMware.Vim.VirtualMachineConfigSpec
$extra=New-ObjectVMware.Vim.optionvalue
$extra.Key="mem.hotadd"
$extra.Value="true"
$vmConfigSpec.extraconfig +=$extra
$vmview.ReconfigVM($vmConfigSpec)
}
FunctionEnable-vCpuHotAdd($vm){
$vmview=Get-vm$vm | Get-View
$vmConfigSpec=New-ObjectVMware.Vim.VirtualMachineConfigSpec
$extra=New-ObjectVMware.Vim.optionvalue
$extra.Key="vcpu.hotadd"
$extra.Value="true"
$vmConfigSpec.extraconfig +=$extra
$vmview.ReconfigVM($vmConfigSpec)
}
$vmlist=Import-CSVC:\csvfile.csv
foreach ($itemin$vmlist) {
$vmname=$item.vmname
Stop-VM-VM$vmname-RunAsync
}
foreach ($itemin$vmlist) {
$vmname=$item.vmname
$cpu=$item.cpu
$mem= [int]$item.mem *1024
Enable-MemHotAdd$vmname
Enable-vCpuHotAdd$vmname
Set-VM-VM$vmname-NumCpu$cpu-MemoryMB$mem-RunAsync-Confirm:$false
}
foreach ($itemin$vmlist) {
$vmname=$item.vmname
Start-VM-VM$vmname-RunAsync
}