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
Above is an example pic of what the script generates and how it should look.
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.]


Izzy77 said...

The Convertto-html using style sheet adds a great face-lift to the generated pages. This is also a great script. I have been looking around, but unable to find a way to list the datastores per cluster. The totals are nice but they can be misleading. I have 1.5TB free of local storage (that is ony used in case scenarios) and about 200GB free of shared. So my percents are skewed because of that. If I could get a list of each cluster and the associated datastores it would more accurately reflect my free/used space. Any idea how to accomplish this?

K. Chris Nakagaki (Zsoldier) said...

That's actually pretty easy. I have another script that does that. I've also rewritten this script completely to run faster, haven't posted yet.

$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.