OK so here’s a quick one.  I know there are many other posts out there about this, i’ve come across multiple ones but again for my own documentation and for the mere fact that usually writing about something helps me to remember it I’m going to throw one more out into the mix.

I’ve occasionally come across a bunch of my VMs which seem for some reason to have a memory limit set on them.  BTW, vCheck is a great tool for reporting on these.   We all know the dangers of memory limits (swapping, ballooning, etc) and to tell you the truth I’m not sure why or how they got set.  I’m assuming I have a template somewhere within my environment which has a limit imposed on it.  Either way, there is a quick and easy way to get rid of those limits using PowerCLI.

First off I wanted to see which VMs had lmits imposed on them from within a certain cluster in my environment.  The following command does just that.

Get-VM -Location CLUSTERNAME | Get-VMResourceConfiguration 
| where {$_.MemLimitMB -ne '-1'} | Select VM,MemLimitMB

Furthermore, If you do have some VMs that you want to have a memory limit set on and not returned here and you have some soft of consistency within their name (ie. Veeam Replica’s) you can do the following to exclude them…

Get-VM -Location CLUSTERNAME | where {$_.Name -notlike '*Replica'} 
| Get-VMResourceConfiguration | where {$_.MemLimitMB -ne '-1'} 
| Select VM,MemLimitMB

You should be left with a listing of your VMs which have a memory limit set on them…

To set these VMs limit to unlimited, just pipe in the Set-VMResourceConfiguration cmdlet as follows

Get-VM -Location CLUSTERNAME | Get-VMResourceConfiguration 
| where {$_.MemLimitMB -ne '-1'} 
| Set-VMResourceConfiguration -MemLimitMB $null

Voila!  No more memory limits…as you can imagine you can do the same with CPULimitMhz.  FYI, if you want to learn more about PowerShell or PowerCLI or scripting you are in the wroooooonnnnggg place, I know what I know, but most examples I get from the following people and you should really follow Alan Renouf (blog/twitter), Luc Dekens (blog/twitter), Jake Robinson (blog/twitter), William Lam (blog/twitter) Eric Wright (blog/twitter), Josh Atwell (blog/twitter) or Hal Rottenberg (blog/twitter).  I’m sure I’m missing a few, these are just the ones I can remember off the top of my head, feel free to recommend some more CMDLET rock stars to me in the comments below…. 🙂