I found a few VMs in my environment that had limits set that were less than their given allocation. This causes the VM to balloon memory nonstop. I ran the script below and can scroll through looking for this issue, but I'm wondering if there's a way to only return VMs that have MemLimit < MemoryMB.
*get-vm | % { get-view $_.ID } | Select-Object Name, *
@{ Name="MemoryMB"; Expression={$_.Summary.Config.memorySizeMB}} ,
@{ Name="MemLimit"; Expression={$_.config.memoryAllocation.limit}}
Here you go jt. This is great, as during the testing of my script I found several VM's previous employees had configured this way which I am now fixing.
Z
Thanks for the reply, that's just what I needed. Glad I could help you discover some unknown issues in your environment.
No worries, it's always fun walking into an environment that others have had their hands on and performing cleanup, and you helped me out.
I made one slight change to the script to prevent it from returning VM's with Limit = -1.
if ($vmMemLimit -ne -1) {
if ($vmMemLimit -lt $vmMem) {
Yep sorry jt I didn't take into account VM's which have unlimited checkbox checked.
Thanks,
Z
do you have the complete script or can you indicate where you made the unlimited change is im having the same problem where random vms are being changed to limited and need to list out the ones that are limited only.
Did you have a look at ?
I think you should find the info you requested in there.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD and Jt exactly what i was looking for.