justinsmith
Enthusiast
Enthusiast

Script to change memory resource setting

I have a bunch of VM's that have the unlimited check box (see attached screen shot) under memory resources UNCHECKED.  Is there a way to script something that will CHECK that box on all my VM's?

0 Kudos
4 Replies
a_p_
Leadership
Leadership

Take a look at http://www.virtu-al.net/2009/07/07/powercli-more-one-liner-power/ to see whether this fits your needs.

André

Discussion moved from VMware vCenter™ Server to VMware vSphere™ PowerCLI

0 Kudos
justinsmith
Enthusiast
Enthusiast

Does this script change it for every VM in the environment? Does it matter if the unlimited box is already checked?

Get-VM | Get-VMResourceConfiguration | Where-Object {$_.MemLimitMB -ne '-1'} | Set-VMResourceConfiguration -MemLimitMB $null

0 Kudos
LucD
Leadership
Leadership

Yes, the Get-VM will return all guests known under your current vSphere Server connection(s).

No, the Where-clause will only pass guests to the Set-VMResourceConfiguration cmdlet that do not have the unlimited box set.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

justinsmith
Enthusiast
Enthusiast

Script worked to perfection... thanks to both you guys!

0 Kudos