The following script was written to solve a problem in our environment where we had a vCenter server that had it’s Statistics Level set much too high. While the high granularity is helpful for a short period of time when troubleshooting an issue it can really grow your vCenter Server database pretty quickly if left at a high level for very long. We needed to know what the settings were in our environment with multiple vCenter Servers.
Luc Dekens ( @LucD22) provides some excellent resources on vCenter Statistics so if you’re unfamiliar then I suggest checking them out. I will skip right to the work I needed.
Goals
Allow user to enter preferred Statistics Level values
Email a daily report and write to date-based file
Check level based on preferred values and report only discrepancies
You will notice in the script that I do not use Get-StatInterval. When issuing that cmdlet it does not give you Statistics Level.
From Luc’s article:
“You define the statistical level for each “historical” interval in the vSphere Client under <Administration><vCenter Server Settings><Statistics>.”
For further breakdown visit my blogpost article at http://www.vtesseract.com/post/8439832274/powercli-vcenter-statistics-level-audit-script