PowerCli to add ram & enable hot add.

Hi All,
I need to add ram to around 300VMs…

I’m a total noob when it comes to PowerCLI, so I’m wondering if anyone has got a script or can help me write one that would allow you to:

-specify a VM name pattern to search for

-shutdown all VMs with matching name

-enable hot add ram

-check if ram is below X value

-if below, increase ram to X

-power up VM


View Reddit by NoDowt_JayView Source

Related Articles


  1. This is a fairly simple task to do with PowerCLI, the following is basically what you need (syntax may not be 100% correct, I’m doing this from memory):

    $vms = get-vm | where {$_.name -like “server[0-9][0-9]”}

    For each($vm in $vms){
    Shutdown-vmguest -name $vm.name
    If ($vm.memory -lt 4000) {
    Set-vm -memoryMB 8000
    Start-vm -name $vm.name

    This will do everything except enable hot add. I have purposely left that out as I don’t recommend using it. It affects the amount of shares each VM consumes for HA calculations and can cause VMs not to power on when they should. I think Duncan Epping wrote a very good article on the impact of hot add and suggest reading it before implementing

    The shutdown-vmguest command requires the VM to have vmtools installed, if they don’t use stop-vm but be aware that this doesn’t shutdown the OS

Leave a Reply