The System Center VMM PowerShell module is very rich and contains more than 400 cmdlets, but it is missing some trivial cmdlets IMO that will help determine if a specific user has enough resources to deploy a new virtual machine or a new service template. Initially it sounds like an easy task, just get the quota and the usage, subtract and return the result, but because VMM has a flexible mechanism to configure quota it becomes a bit trickier. There are 4 factors to consider when checking for enough resources:
- Template required resources
- Destination cloud capacity/usage
- User-Role quota/usage
- User account quota/usage
And for each factor there are 5 categories that need to be validated:
- Total CPU number
- Total virtual machine number
- Total memory amount
- Total storage amount
- Total custom points
To fulfill this need I developed the following 3 PowerShell functions:
- Get-SCServiceTemplateResources – Iterates over the service template tiers and aggregates the required resources
- Get-SCUserAvailableResource – Retrieves user’s available resources for a given cloud and user-role. The calculation considers the user-role quota, user quota, cloud capacity, user-role usage, user usage and cloud usage
- HasResourceForNewService – uses the above 2 functions to return a Boolean result of whether or not the user has the sufficient resources for the new service deployment