Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Total number of hosts
- $TotalVMHosts = (Get-VMHost).Count
- Write-Host "There are $TotalVMHosts Hosts in $DefaultVIServer"
- # Total number of guests
- $TotalVMs = (Get-VM).Count
- Write-Host "There are $TotalVMs Virtual Machines in $DefaultVIServer"
- $Clusters = Get-Cluster
- #Per cluster Stats
- foreach ($Cluster in $Clusters){
- # Average VMs Per Cluster
- $VMHosts = Get-Cluster $Cluster | Get-VMHost
- $VMs = Get-Cluster $Cluster | Get-VM
- $AverageVMsPerCluster = [math]::round(($VMs.count / $VMHosts.count), 1)
- Write-Host "$Cluster has $AverageVMsPerCluster guests per VMware host"
- #Per host Stats
- foreach ($VMHost in $VMHosts){
- #Memory Usage and Overcommit
- $VMs = Get-VMHost $VMHost | Get-VM
- $VMStats = $VMs | Measure-Object -property MemoryMB -sum
- $AllocatedMem = [math]::round($VMStats.sum /1024,2)
- $PhysicalMem = [math]::round($VMHost.MemoryTotalMB /1024,2)
- $UsedMem = [math]::round($VMHost.MemoryUsageMB /1024,2)
- $PUsedMem = [math]::round(($UsedMem/$PhysicalMem)*100,2)
- $PAllocMem = [math]::round(($AllocatedMem/$PhysicalMem)*100,2)
- Write-Host "$VMHost has $PhysicalMem GB of RAM $UsedMem is in use($PUsedMem %), $AllocatedMem is Allocated ($PAllocMem %)"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment