This script will do the following:

1. Get the count of all CPU cores on the given Hyper-V Host, locally or remotely (for remote, it uses Invoke-Command for remote query, so does NOT require Hyper-V modules to be locally installed)

2. Get the count of virtual CPU cores assigned to each RUNNING VM on the Host

3. Display the Total and individual CPU counts for all RUNNING VMs on the Host

4. If over-provisioned, display a warning

 

EXAMPLE:

.\Get-VMHostCPUAllocation.ps1 -VMHost MYHYPERV1

Getting CPU allocation on Hyper-V Host: (MYHYPERV1)

-----------------------------------------------------
Total Physical CPU cores:               16
Total vCPUs used by RUNNING VMs:        18  <-- WARNING: CPUs over-provisioned

Getting CPU allocation per RUNNING VM...
-----------------------------------------------------

Name           ProcessorCount
----           --------------
SERVERVM1                   2
SQLSERVER1                  12
WEBSERVER1                  2
RDSSERVER1                  2