VMware Cloud Community
romatlo32
Enthusiast
Enthusiast

Schedule an increase to RAM?

Hi Folks,

I am noticing that I am unable to increase RAM because grayed out, hot plug disabled, understood.

however, when trying schedule this task after a power off scheduled task, still grayed out.  Is that correct?

Reply
0 Kudos
7 Replies
StephenMoll
Expert
Expert

Only things I can think of:

(1) The virtual hardware dialogue for the VM will need to be closed and reopened to see a change in state. Powering down the VM with the dialogue open will not dynamically change the status of the dialogue, e.g. unfreezing greyed out controls. Sometime the main web client view can benefit from a refresh too.

(2) How much vRAM are we talking about. Is it already at the maximum for the licensed state of the host?

Reply
0 Kudos
romatlo32
Enthusiast
Enthusiast

Thanks for responding!

I understand when editing settings, memory settings are grayed out because we do not enable memory hot plug.

However, I was hoping that the task scheduler would except me to schedule a Shutdown Guest VM, then allow a second subsequent scheduled task to increase the RAM.

I've added the Shutdown task, and now trying to add an Edit Resource settings task, but RAM is still grayed out.  Pic attached...

Looks like I just can't do it, and will have to manually babysit it to get it done....

Reply
0 Kudos
StephenMoll
Expert
Expert

That looks like the wrong dialogue. That is the resource allocation settings dialogue. You want the VM virtual hardware dialogue.

Reply
0 Kudos
StephenMoll
Expert
Expert

I don't have access to my system at the moment, but found this picture via Google so hopefully it shows here:

2-10.png

You want "Edit Settings...", not "Edit Resource Settings...".

Reply
0 Kudos
romatlo32
Enthusiast
Enthusiast

Thank you again!  But seems like we are talking about different stuff.

I am talking about scheduling a new task.  Actually, looks like there is no Edit Settings option.

See pic...

vspheresettings.jpg

Reply
0 Kudos
TheBobkin
Champion
Champion

Hello romatlo32​,

There is no scheduled task setting for increasing the assigned Memory to a VM - only changing the reservations etc. as you have in your screenshot. The Memory cannot be increased in the state of the VM being powered-on due to Memory Hot Plug not being enabled as you understand.

The likely only way to achieve this would be via PowerCLI or some other timed script for editing the VMs settings while it is powered-off - if you are only planning on doing this for 1/few VM's then better to just do it manually (unless that is you also care about learning about how this can be orchestrated in which case research the automation processes).

Bob

Reply
0 Kudos
vmtechwpg
Contributor
Contributor

Just run this in powershell.   works great, add it as a scheduled task with the flags

 

###################################################################
# Change-VM_Memory_CPU_Count.ps1
#
# -MemoryMB the amount of Memory you want
# to add or remove from the VM in MB
# -MemoryOption Add/Remove
# -CPUCount the amount of vCPU's you want
# to add or remove from the VM
# -CPUOption Add/Remove
#
# Example:
# .\Change-VM_Memory_CPU_Count.ps1 -vCenter vc01
# -vmName NAGIOS -MemoryMB 512 -MemoryOption Add
# -CPUCount 1 -CPUOption Remove
#

# REAL EXAMPLE

# 1GB = 1024
# 2GB = 2048
# 4GB = 4096
# 6GB = 6144
# 8GB = 8192

 

####################################################################

param(
[parameter(Mandatory = $true)]
[string[]]$vCenter,
[parameter(Mandatory = $true)]
[string]$vmName,
[int]$MemoryMB,
[string]$MemoryOption,
[int]$CPUCount,
[string]$CPUOption
)

function PowerOff-VM{
param([string] $vm)

Shutdown-VMGuest -VM (Get-VM $vm) -Confirm:$false | Out-Null
Write-Host "Shutdown $vm"
do {
$status = (get-VM $vm).PowerState
}until($status -eq "PoweredOff")
return "OK"
}

function PowerOn-VM{
param( [string] $vm)

if($vm -eq ""){ Write-Host "Please enter a valild VM name"}

if((Get-VM $vm).powerstate -eq "PoweredOn"){
Write-Host "$vm is already powered on"}

else{
Start-VM -VM (Get-VM $vm) -Confirm:$false | Out-Null
Write-Host "Starting $vm"
do {
$status = (Get-vm $vm | Get-View).Guest.ToolsRunningStatus
}until($status -eq "guestToolsRunning")
return "OK"
}
}

function Change-VMMemory{
param([string]$vmName, [int]$MemoryMB, [string]$Option)
if($vmName -eq ""){
Write-Host "Please enter a VM Name"
return
}
if($MemoryMB -eq ""){
Write-Host "Please enter an amount of Memory in MB"
return
}
if($Option -eq ""){
Write-Host "Please enter an option to add or remove memory"
return
}

$vm = Get-VM $vmName
$CurMemoryMB = ($vm).MemoryMB

if($vm.Powerstate -eq "PoweredOn"){
Write-Host "The VM must be Powered Off to continue"
return
}

if($Option -eq "Add"){
$NewMemoryMB = $CurMemoryMB + $MemoryMB
}
elseif($Option -eq "Remove"){
if($MemoryMB -ge $CurMemoryMB){
Write-Host "The amount of memory entered is greater or equal than
the current amount of memory allocated to this VM"
return
}
$NewMemoryMB = $CurMemoryMB - $MemoryMB
}

$vm | Set-VM -MemoryMB $NewMemoryMB -Confirm:$false
Write-Host "The new configured amount of memory is"(Get-VM $VM).MemoryMB
}

function Change-VMCPUCount{
param([string]$vmName, [int]$NumCPU, [string]$Option)
if($vmName -eq ""){
Write-Host "Please enter a VM Name"
return
}
if($NumCPU -eq ""){
Write-Host "Please enter the number of vCPU's you want to add"
return
}
if($Option -eq ""){
Write-Host "Please enter an option to add or remove vCPU"
return
}

$vm = Get-VM $vmName
$CurCPUCount = ($vm).NumCPU

if($vm.Powerstate -eq "PoweredOn"){
Write-Host "The VM must be Powered Off to continue"
return
}

if($Option -eq "Add"){
$NewvCPUCount = $CurCPUCount + $NumCPU
}
elseif($Option -eq "Remove"){
if($NumCPU -ge $CurCPUCount){
Write-Host "The number of vCPU's entered is higher or equal
than the current number of vCPU's allocated to this VM"
return
}
$NewvCPUCount = $CurCPUCount - $NumCPU
}

$vm | Set-VM -NumCPU $NewvCPUCount -Confirm:$false
Write-Host "The new configured number of vCPU's is"(Get-VM $VM).NumCPU
}

#######################################################################################
# Main script
#######################################################################################

$VIServer = Connect-VIServer $vCenter
If ($VIServer.IsConnected -ne $true){
Write-Host "error connecting to $vCenter" -ForegroundColor Red
exit
}

if($MemoryMB -or $CPUCount -ne "0"){
$poweroff = PowerOff-VM $vmName
if($poweroff -eq "Ok"){
Write-Host "PowerOff OK"

if($MemoryMB -ne "0"){
if($MemoryOption -eq " ") {Write-Host "Please enter an option to add or remove memory"}
else{
Change-VMMemory $vmName $MemoryMB $MemoryOption
}
}

if($CPUCount -ne "0"){
if($CPUOption -eq " ") {Write-Host "Please enter an option to add or remove cpu"}
else{
Change-VMCPUCount $vmName $CPUCount $CPUOption
}
}

$poweron = PowerOn-VM $vmName
if($poweron -eq "Ok"){
Write-Host "PowerOn OK"}
}
}

Disconnect-VIServer -Confirm:$false

Reply
0 Kudos