VMware Cloud Community
jt30605
Contributor
Contributor
Jump to solution

Finding Memory Limit < Allocation

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 &lt; MemoryMB.

*get-vm | % { get-view $_.ID } | Select-Object Name, *

@{ Name="MemoryMB"; Expression={$_.Summary.Config.memorySizeMB}} ,

@{ Name="MemLimit"; Expression={$_.config.memoryAllocation.limit}}

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
240Zeus
Enthusiast
Enthusiast
Jump to solution

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

View solution in original post

Reply
0 Kudos
9 Replies
240Zeus
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
jt30605
Contributor
Contributor
Jump to solution

Thanks for the reply, that's just what I needed. Glad I could help you discover some unknown issues in your environment. Smiley Happy

Reply
0 Kudos
240Zeus
Enthusiast
Enthusiast
Jump to solution

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. Smiley Happy

Reply
0 Kudos
jt30605
Contributor
Contributor
Jump to solution

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) {

Reply
0 Kudos
240Zeus
Enthusiast
Enthusiast
Jump to solution

Yep sorry jt I didn't take into account VM's which have unlimited checkbox checked.

Thanks,

Z

Reply
0 Kudos
rDale
Enthusiast
Enthusiast
Jump to solution

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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
jt30605
Contributor
Contributor
Jump to solution

Here's a script that exports the results as a csv file.

Reply
0 Kudos
rDale
Enthusiast
Enthusiast
Jump to solution

Thanks LucD and Jt exactly what i was looking for.

Reply
0 Kudos