param (
[Parameter(Mandatory=$true)]
[VMware.VimAutomation.ViCore.Types.V1.Inventory.Cluster[]] $cluster,
[Parameter(Mandatory=$true)]
[string] $smtp,
[Parameter(Mandatory=$true)]
[string] $email)
$vms = Get-VM -Location $cluster
$snapshots = @()
foreach ($vm in $vms) {
$snapshots += Get-Snapshot -VM $vm
}
$header = @"
"@
$snapshots | select Name,VM,Created,@{Name="Size";Expression={[math]::Round($_.SizeMB,3)}},IsCurrent | `
ConvertTo-Html -head $header | Out-File "SnapshotReport.html"
Send-MailMessage -from "Snapshot Reports " `
-to $email `
-subject "Snapshot Report" `
-body "Cluster snapshot report" `
-Attachment "SnapshotReport.html" `
-smtpServer $smtp