A comprehensive PowerShell tool for automated VMware snapshot monitoring and reporting with color-coded HTML email notifications.
- π Comprehensive Reporting: Detailed snapshot analysis with statistics and summaries
- π¨ Color-Coded Risk Assessment:
- π’ Green: Low risk (< 2 days old)
- π‘ Yellow: Medium risk (2-3 days old)
- π΄ Red: High risk (3+ days old)
- π§ HTML Email Reports: Beautiful, responsive email notifications
- βοΈ Configurable Thresholds: Customize risk assessment criteria
- π± Mobile-Friendly: Responsive design for all devices
- π Secure: Support for credential files and encrypted passwords
- π§ͺ Test Mode: Validate configuration without sending emails
- πΎ Backup Reporting: Automatic file backup when email fails
- Windows PowerShell 5.1 or later
- VMware PowerCLI module
- vCenter Server access (read-only minimum)
- SMTP Server access for email notifications
-
Install VMware PowerCLI (if not already installed):
Install-Module -Name VMware.PowerCLI -Force -AllowClobber
-
Download the script:
git clone https://github.com/canberkys/VMware-Snapshot-Reporter/git cd VMware-Snapshot-Reporter -
Configure the script (see Configuration section below)
Before running the script, update the configuration section at the top of VMware-Snapshot-Reporter.ps1:
$VCenterConfig = @{
Server = "your-vcenter-server.domain.com" # REQUIRED: Your vCenter FQDN/IP
Username = "your-service-account@domain.com" # REQUIRED: Service account
Password = "your-secure-password" # REQUIRED: Account password
# CredentialPath = "C:\Secure\vcenter-creds.xml" # OPTIONAL: Credential file
}$EmailConfig = @{
SmtpServer = "your-smtp-server.domain.com" # REQUIRED: SMTP server
SmtpPort = 25 # OPTIONAL: SMTP port (25, 587, 465)
From = "vmware-reports@your-domain.com" # REQUIRED: Sender email
To = @("it-team@your-domain.com") # REQUIRED: Recipient emails
CC = @("manager@your-domain.com") # OPTIONAL: CC recipients
Subject = "VMware Snapshot Report - {0}" # Email subject template
}$RiskConfig = @{
HighRiskDays = 3 # Snapshots older than 3 days = Red
MediumRiskDays = 2 # Snapshots 2-3 days old = Yellow
# Snapshots < 2 days = Green
}# Create encrypted credential file
Get-Credential | Export-CliXml -Path "C:\Secure\vcenter-creds.xml"
# Update configuration to use credential file
$VCenterConfig = @{
Server = "your-vcenter-server.domain.com"
CredentialPath = "C:\Secure\vcenter-creds.xml"
}# Set environment variables
$env:VCENTER_USERNAME = "service-account@domain.com"
$env:VCENTER_PASSWORD = "secure-password"
# Update configuration
$VCenterConfig = @{
Server = "your-vcenter-server.domain.com"
Username = $env:VCENTER_USERNAME
Password = $env:VCENTER_PASSWORD
}.\VMware-Snapshot-Reporter.ps1.\VMware-Snapshot-Reporter.ps1 -TestMode.\VMware-Snapshot-Reporter.ps1 -SaveToFile -OutputPath "C:\Reports\snapshot-report.html".\VMware-Snapshot-Reporter.ps1 -ConfigFile "C:\Config\production-config.ps1".\VMware-Snapshot-Reporter.ps1 -TestMode -SaveToFile -OutputPath "C:\Reports\test-report.html"[2025-09-28 10:30:15] [INFO] VMware Snapshot Reporter v2.0 starting...
[2025-09-28 10:30:15] [INFO] vCenter: vcenter.company.com
[2025-09-28 10:30:16] [SUCCESS] Successfully connected to vCenter: vcenter.company.com
[2025-09-28 10:30:18] [SUCCESS] Successfully processed 5 snapshots
[2025-09-28 10:30:18] [SUCCESS] === SNAPSHOT REPORT SUMMARY ===
[2025-09-28 10:30:18] [SUCCESS] Total Snapshots: 5
[2025-09-28 10:30:18] [SUCCESS] Total Size: 125.6 GB
[2025-09-28 10:30:18] [SUCCESS] Risk Distribution: High=1, Medium=2, Low=2
[2025-09-28 10:30:19] [SUCCESS] Email report sent successfully
- Executive Summary: Total snapshots, size, and oldest snapshot age
- Risk Assessment: Color-coded breakdown of snapshot ages
- Detailed Table: Complete snapshot inventory with:
- VM Name
- Snapshot Name
- Creation Date
- Age in Days (color-coded)
- Description
- Size (color-coded)
- Creator Username
Create a scheduled task to run daily:
# Create scheduled task
$Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-File C:\Scripts\VMware-Snapshot-Reporter.ps1"
$Trigger = New-ScheduledTaskTrigger -Daily -At "09:00AM"
$Settings = New-ScheduledTaskSettingsSet -ExecutionTimeLimit (New-TimeSpan -Hours 1)
$Principal = New-ScheduledTaskPrincipal -UserId "DOMAIN\ServiceAccount" -LogonType ServiceAccount
Register-ScheduledTask -TaskName "VMware Snapshot Report" -Action $Action -Trigger $Trigger -Settings $Settings -Principal $Principal# Add to crontab (run daily at 9 AM)
0 9 * * * /usr/bin/pwsh -File /opt/scripts/VMware-Snapshot-Reporter.ps1Install-Module -Name VMware.PowerCLI -Force -AllowClobber -Scope CurrentUserThe script automatically ignores invalid certificates, but you can also:
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$falseUpdate email configuration:
$EmailConfig = @{
SmtpServer = "smtp.office365.com"
SmtpPort = 587
UseSSL = $true
Username = "smtp-user@domain.com"
Password = "app-password"
# ... other settings
}Test connectivity:
Test-NetConnection your-vcenter-server.domain.com -Port 443
Test-NetConnection your-smtp-server.domain.com -Port 25Add verbose logging:
$VerbosePreference = "Continue"
.\VMware-Snapshot-Reporter.ps1 -Verbose$RiskConfig = @{
HighRiskDays = 7 # Weekly cleanup cycle
MediumRiskDays = 3 # 3-day warning period
}$EmailConfig = @{
To = @(
"primary-admin@company.com",
"backup-admin@company.com",
"infrastructure-team@company.com"
)
CC = @(
"manager@company.com",
"director@company.com"
)
}$ReportConfig = @{
PoweredOnOnly = $false # Include powered-off VMs
MaxEventSamples = 2000 # Increase event history
SortBySize = $false # Sort by age instead of size
}- Large Environments: Increase
MaxEventSamplescarefully as it affects performance - Network Latency: Consider running the script from a server close to vCenter
- Concurrent Access: Multiple scripts can run simultaneously against different vCenters
- Memory Usage: Large environments may require PowerShell memory optimization
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Wiki: Project Wiki
- VMware PowerCLI team for the excellent PowerShell module
- Community contributors for feedback and improvements
- IT Operations teams worldwide using this tool
- Language: PowerShell
- Lines of Code: ~500
- File Size: ~25KB
- Tested On:
- vCenter 6.7, 7.0, 8.0
- PowerShell 5.1, 7.x
- Exchange Server, Office 365, Gmail SMTP
β Star this repository if you find it useful!
π Found a bug? Report it here
π‘ Have an idea? Share it with us
