New Powershell VMWare Summary Report Script using functions
UPDATED and Optimized Script can be found HERE.
I'm hoping this is easier to read for any interested. Things I track in this script are as follows:
- Cluster Name
- # of Effective Cluster Hosts
- # of VM's in the cluster
- # of allocated vCPU's
- VMWare supported maximum of vCPU's per core
- Datastore full size
- Datastore free space
- Datastore used space as a percentage
The script is posted here. I suggest copying and pasting into a Powershell editor like PowerGUI or Powershell PLUS for readability.
It automatically generates an html and stylesheet file and places them on your C drive. You can change a bunch of variables that are commented toward the top of the script. Hope you can find this useful.
[Update: I've added sort capability to the code via a Javascript library which can be downloaded here.]
Comments
$clusters = Get-Cluster |
ForEach ($cluster in $clusters)
{
$vmhosts = Get-VMHost -Location $cluster | Get-Datastore | where {$_.Name -inotmatch 'Inventory'} |
Select Name,
@{Name='Available(GB)';expression={"{0:n2} GB" -f ($_.FreeSpaceMB/1kb)}},
@{Name='UsedGB';expression={"{0:n2} GB" -f (($_.CapacityMB - $_.FreeSpaceMB)/1kb)}},
@{Name='% Used';expression={"{0:n2} %" -f ((($_.capacitymb - $_.freespacemb)/$_.capacitymb) * 100)}},
@{Name='Capacity(GB)';expression={"{0:n2} GB" -f ($_.CapacityMB/1kb)}}`
| Sort '% Used' -Descending | `
ConvertTo-Html –body "$cluster cluster" -head "Datastores by cluster " | Out-File -Encoding ASCII -Append $DataStoresByCluster
Clear-Variable vmhosts -ErrorAction SilentlyContinue}
This is totally unoptimized, I'm working on rewriting this as well.