This script is also already from a while ago, but I’m posting this because it might be useful to anyone that is currently investigating virtual machine limits and reservation performance issues on their environment or are simply looking for a quick check on their environment.

Configuring limits on virtual machine resources such as RAM, CPU cycles and IOPS is not a bad thing to do if the environment needs this to function properly. It can be used to manage situations in which contention comes up, so that your production virtual machines can still use all of the resources they need, but the test environments simply can’t use more resources because of the configured limits. Same goes with reservations. If you want to be sure that your production environments get the resources they need in case of contention, configure a resource reservation on them! This ensures that your production virtual machines always get the amount of resources you have reserved for them. In cases with exteme contention these virtual machines will probably still get slower and have performance impact! Don’t forget to size your environment correctly!

Anyway, a while ago I had to take over another environment and at some point a colleague of mine came to me and said that one of the domain controllers was having performance related issues, but the rest of the virtual machines were not affected. So at that point it directly rang a bell and I told him to check the resource reservations and limits and as you can guess, it had a limit configured which was far less than the amount of configured resources on the virtual machine. After I fixed this by removing the limit, I wanted to check the complete environment so that this could not happen again in the future. For this situation I created the below script:

I wanted it to be in some sort of report so that I could have it mailed to myself everytime I take over a new environment. That’s the reason it’s in a table format. This script basically reads all virtual machines in the environment, checks if there is A- a limit on the virtual machine and B- checks if that limit is less than the amount of configured RAM and C- checks if there is any reservation. If the RAM limit is more than what is configured as RAM it doesn’t really matter, because it will never have any impact from the limit (unless you increase the RAM and forget to delete the limit). Secondly it checks the same for the CPU resources. If one of these variables don’t check out, it gives you a nice “PleaseFix” column with a “Yes” or a “No”. See below for some sample output:

A quick one liner for the limits could also be the following script:

If any of the values under “MemLimitGB” and “CPULimitMhz” are above “-1”, which is unlimited, there is a limit configured of some sorts.

If you want to quickly remove a limit on a virtual machine you could use the following one liner:

There you have it, a nice PowerCLI script and a one-liner to do a quick check on your enviroment for limits and reservations together with a quick way to remove them! Want to know more PowerCLI tips and tricks? Click on the button below:

Share this if you found this interesting.

Leave a Reply

Your email address will not be published. Required fields are marked *