Custom shares on a Resource Pool, scripted (Modified)

Well I’ve been taking a bit of a break from XML-based powershell code, ‘coz it was doing my head in working with that. I was going through some older blog posts on YellowBricks and stumbled across a few related to Resource Pools, specifically related to how shares work.

Now I was always under the impression that shares were already weighted to account for the number and size of VM’s in them… however I was clearly mistaken. I did actually raise this question during my vSphere training and was assured that was the case…. so it’s definitely something to be aware of. The Resource Pool Priority Pie Paradox

My immediate reaction to this was “Oh Sh!t, my resource pools wont be working as expected then, better put on the scripting hat”…. but I’d been beaten to the punchline. Duncan and Andrew Mitchell have kindly shared their work, Here.

So firstly, Thanks to Andrew and Duncan for posting this, it saved me a lot of time and it’s beautifully coded and extensively commented. However, in my environment, we have several clusters with the same pool requirements (legacy hardware, incompatible CPUIDs etc)… so it made sense to encapsulate the guts of the code in a ForEach loop. I had to add some logic to accomplish this and while I was at it, I added secure credential storage so the script can be run as a scheduled task. I allowed the script to either loop through all clusters or for them to be specified in an array.

I also opted to take Horst Mundt’s advice of modifying the shares to be an order of magnitude higher. This was done to get around the problem of other resource pools with default settings taking a large slice of resources.

Once again, all credit to Andrew and Duncan… my part was very small indeed.

Download my version Here: Set_Weighted_Shares.ps1 (Rename to .ps1)

Hope this is helpful to someone :)

2 Responses to “Custom shares on a Resource Pool, scripted (Modified)”

Leave a Reply

The opinions expressed on this site are my own and not necessarily those of my employer.

All code, documentation etc is my own work and is licensed under Creative Commons and you are free to use it, at your own risk.

I assume no liability for code posted here, use it at your own risk and always sanity-check it in your environment.