Over the last few years I've been using and tweaking a PowerShell script that generates an HTML report that provides information about a Hyper-V host and running virtual machines. This is another great use case for a PowerShell control script. The script helps me organize commands like Get-CimInstance, Get-VM and Get-Counter to retrieve pieces of data and pull them all together into an HTML report.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
The script accepts parameters and has comment-based help.
This version of the script does not require anything to be installed locally, not even the Hyper-V cmdlets. The script uses PowerShell remoting and gathers all the information from a Hyper-V host that you specify. If necessary, you can use alternate credentials. If you are like me and use Hyper-V on Windows 10, the Computername parameter defaults to the localhost.
The script gathers a wide range of information and creates HTML fragments. At the end of the script, a file is created locally. The script embeds the CSS style sheet as well as any logo graphic you might specify. This makes the file completely portable, say if you wanted to email it with Send-MailMessage or something similar.
Here are a few script features:
- Collapsible regions
- Performance Counters
- Resource Metering reporting
- Replication reporting
- Find virtual machines created in last X number of days (default 30)
- Find virtual machines not used in X number of days (default 30
Currently, the script only supports WSMan remoting so you must have a Windows client. Although PowerShell 7 should work just fine. At some point I might add SSH support so you can run this from a non-Windows client.
Here's a sample report. The collapsible regions may not work in this display or every browser.
You can find the complete script on GitHub.
Be sure to test this script in a non-production setting. It is only getting information but still, you want to make sure the script does what you think it is going to do. If you have questions or comments I'd love to hear them.