mirror of
https://github.com/tsmagnum/Hyper-V-Report.git
synced 2026-04-17 21:54:09 +02:00
b3bb42176308547b9b178310225531bc0a71ebe3
Hyper-V Report Script Documentation
Overview
This PowerShell script automates the collection of detailed information about a Hyper-V environment, including hosts, virtual machines, snapshots, replication status, virtual hard disks (VHDX), network adapters, and virtual switches. It generates an HTML report and optionally sends it via email. Support for clustered environments will be introduced in a future release.
Notice: Please be aware that the script installs the MS Graph or Send-MailKitMessage PowerShell modules if they are not already present. Do not run the script if installing these modules could cause issues in your environment.
Features
- Collects host system information
- Enumerates all virtual machines and their configurations
- Lists VM snapshots and calculates their age
- Reports replication status for VMs
- Gathers VHDX file details
- Extracts VM and management OS network adapter data
- Lists virtual switch configurations
- Generates a comprehensive HTML report
- Sends the report via email using MS Graph or MailKit
Prerequisites
- PowerShell 5.1 or later
- Hyper-V role installed
- Required modules:
Hyper-VCimCmdlets
- External scripts in the same directory:
GlobalVariables.ps1StyleCSS.ps1HtmlCode.ps1Functions.ps1
Script Parameters
These are expected to be defined in GlobalVariables.ps1:
$reportHtmlDir– Directory to save the HTML report$reportHtmlName– Base name for the report file$clusterDeployment– Boolean flag for cluster support$replicationInfoNeeded– Boolean flag to include replication info$vhdxInfoNeeded– Boolean flag to include VHDX info$vmnetInfoNeeded– Boolean flag to include VM network adapter info$osNetInfoNeeded– Boolean flag to include management OS network adapter info$vswitchInfoNeeded– Boolean flag to include virtual switch info$reportHtmlRequired– Boolean flag to generate HTML report$emailReport– Boolean flag to send report via email$emailSystem– Email system to use (msgraphormailkit)
Output
- HTML Report: Saved in
$reportHtmlDirwith timestamped filename. - Console Output: Displays formatted tables for each section.
- Email: Sent if
$emailReportis enabled and$reportHtmlRequiredis true.
Usage
.\Hyper-V-Report.ps1
Ensure all required variables and modules are properly configured before execution.
Sections in the Report
- Host Info – CPU, RAM, OS version, VHD volume stats
- VM Info – Name, generation, memory, IP, state, uptime, replication
- Snapshots – Snapshot name, age, parent snapshot
- Replication – Status, health, last replication time
- VHDX Info – Format, type, size, fragmentation
- VM Network Adapters – MAC, IP, vSwitch, VLAN
- Management OS Adapters – IP, MAC, vSwitch, VLAN
- Virtual Switches – Name, type, uplinks, SET status
Notes
- Cluster support is marked as "Coming soon".
- Email system must be explicitly selected (
msgraphormailkit).
Languages
PowerShell
100%