Share via


System Center VMM 2012 R2 – How to Change Memory Configuration on all Guest VMs in Mass

Recently i started setting up my lab and working more with System Center Virtual Machine Manager 2012 R2 and found out fast that i was running out of available Memory on my Guest machines.  Typically you would add more RAM to the Host server or migrate guest machines to another host with more resources but my lab is rather small and in need of some new equipment so i have to make due for the time being…

The problem i faced is that i was looking online and found a lot of great posts for previous versions of VMM, but it appears as if we have changed cmdlets during releases so i had to whip up a quick script to accomplish this as i didn't want to manually shutdown and alter the settings of each guest machine.  The below code will connect to the host server specified and get all Guest VMs that are not in the exclude list and start to shut them down and configure Dynamic Memory with a startup value of 512MB, Minimum value of 32MB and Maximum value of 8096MB and then start the Guest VM backup.

https://technet.microsoft.com/en-us/library/jj654428(v=sc.20).aspx

Tested on Virtual Machine Manager 2012 R2:

 $VMs = Get-SCVirtualMachine -VMHost "VMHOSTServer" | Where-Object {$_.Name -notlike "VMsToExclude"}
Foreach ($VM in $VMs) {
Write-Host "Changing Dynamic Memory Values on Machine:" $VM.ComputerName
Shutdown-VM -VM $VM -ErrorAction SilentlyContinue
Set-SCVirtualMachine -VM $VM -DynamicMemoryEnabled $True
Set-SCVirtualMachine -VM $VM -DynamicMemoryMaximumMB 8096
Set-SCVirtualMachine -VM $VM -DynamicMemoryMinimumMB 32
Set-SCVirtualMachine -VM $VM -MemoryMB 512
Start-VM -VM $VM
}

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified
in the
Terms of Use .

Comments

  • Anonymous
    January 01, 2003
    Thank You Mr. Brandon.