https://davidstamen.com/2015/01/14/powercli-enable-cpu-and-memory-hotadd/
I've found this method to set hotadd using Powercli but it only works up to Vsphere 6.5. It doesn't work for latest 6.7 and I can't find any resource online how to fix this. I've tried older versions of Powercli as well as latest Powercli 11.3 but nothing works and no errors when running this script. I've tried rebooting or leaving the VM powered off when running it but nothing works on Vsphere 6.7. Anyone have any ideas? Is there a new cmdlet in PowerCli I should use?
Just place a Write-Host or Select-Object inside the If-block
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This did not work.
Guess I'm doing it wrong.
Also, I tried using Start-transcript but it was of no help here. Pls suggest.
if(-not $vm.ExtensionData.Config.cpuHotAddEnabled -or -not $vm.ExtensionData.Config.memoryHotAddEnabled)
{
myfunctionname $vm
Write-Host "xxx"
}
What does the rest of your code look like?
That should probably be
Write-Host $vm.Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If any VM fails to reconfigure it should mention VM not reconfigured or anything better or log from vcentre itself.
& VM's successfully reconfigured should be mentioned as successfully reconfigured // anything better or log from vcentre itself
Also, what should be the syntax to take VM's from a cluster given that we already provide the cluster name in the script
Function memcpu($vm){
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.CpuHotAddEnabled = $true
$spec.MemoryHotAddEnabled = $true
$vm.ExtensionData.ReconfigVM($spec)
}
Get-Content "path-to-vm-list" | %{
$vm = Get-VM -Name $_
if(-not $vm.ExtensionData.Config.cpuHotAddEnabled -or -not $vm.ExtensionData.Config.memoryHotAddEnabled)
{
memcpu $vm
Write-Host $vm.Name
}
}
Since we are calling an API method, catching faults in the call is a bit more tricky.
To start from a cluster, you could just do
Get-Cluster -Name xyz | Get-VM
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference