My first blog post and it is not even something specific from myself… But sometimes you just have to write about something you discovered on the web, and that is just fantastic… I am a big fan of PowerShell (OK, I am a huge fan of Hyper-V first, but I like to do as much as possible with PowerShell so automatically I am a fan of PowerShell also ) and one of the Hyper-V MVP’s has written a PowerShell script that is absolutely brilliant.
The MVP, Serhat AKINCI (http://www.serhatakinci.com/ or https://twitter.com/serhatakinci) has built a PowerShell script of over 2600+ lines that contains PowerShell, HTML, CSS and WMI. It produces a very nice HTML webpage with lots of information about your hyper-v environment.
The script requires an AD membership and runs on a cluster or standalone hosts for Windows Server 2012 (R2) and Hyper-V server 2012 (R2). It does have a few more requirements such as PowerShell 3.0 or 4.0 but some modules but mostly these will be already installed, unless you will be running the script remotely from a workstation.
It supports parameters also. The script, called Get-HyperVReport.ps1, accepts the following parameters:
- -Cluster <nameofcluster>. This will give you the information about your cluster.
- -Cluster <nameofcluster> –HighlightsOnly. This will give you only highlighted events and alerts
- -VMHost <nameofhost>. This will give you the report for the host, and if you want a report for multiple hosts you can user <nameofhost>, <nameofhost2>, <nameofhost3>
- -Cluster <nameofhost> -SendMail $true -SMTPServer smtp.mailserver.com -SMTPPort 587 –MailFrom <email-adress> –MailFromPassword <password> -SMTPServerTLSorSSL $true -MailTo email@example.com,firstname.lastname@example.org. This will send the report through an SMTP server (pwd protected in this case) to different recepients.
But of course, the most interesting thing is to find out what kind of data this report generates (and it is A LOT). For this report, I used a standalone host to see what it delivers
First you get the information about the host. data such as State, Uptime, the domain, the # of VM, # of CPU, Used, Free and Total RAM are displayed as well (see the little asterisks) some additional info.
The second table gives you more information about your disks such as State, Usage, Owner, Bus Type and many more. Again valuable information that can be used in your CMDB if necessary. Normally this doesn’t change a lot, but for example the last column will tell you the percentage free. If you run this script regularly (or maybe schedule it or so…) you can follow what is happening with your storage.
The last table will give you your VMs and their information such as generation, clusteredresource or not, state, uptime, vCPU, vRAM (including Min/Mx and Assigned) and so on…
A much larger report with more different states can be viewed on the website of the author himself: http://www.serhatakinci.com/files/get-hypervreport-v1-0-demo-output.html and if you are interested (and you should ) then you can get all the information and download from here: https://gallery.technet.microsoft.com/Hyper-V-Reporting-Script-4adaf5d0
If you are running a Hyper-V environment, and you don’t have a monitoring tool in place, this certainly will be of use. Even if it is run on an irregular base. Of course it is not a replacement for a monitoring solution, but I am convinced it will come in handy for a specific reason
Enjoy the script, and do sent feedback to the author (and maybe even enhancement requests? )