VMware Cloud Community
arvin1201
Contributor
Contributor

Snapshot details to email

Hi  Team,

Is there any script which we can use for daily check for snapshots which directly comes to our mailbox

Please suggest.

Thanks

Reply
0 Kudos
5 Replies
pwilk
Hot Shot
Hot Shot

What about something like this?

$Report = Get-VM | Get-Snapshot | Select VM,Name,Description,@{Label="Size";Expression={"{0:N2} GB" -f ($_.SizeGB)}},Created
If (-not $Report)
{ $Report = New-Object PSObject -Property @{
  VM = "No snapshots found on any VM's controlled by $VIServer"
  Name = ""
  Description = ""
  Size = ""
  Created = ""
  }
}
$Report = $Report | Select VM,Name,Description,Size,Created | ConvertTo-Html -Head $Header -PreContent "<p><h2>Snapshot Report - $VIServer</h2></p><br>" | Set-AlternatingRows -CSSEvenClass even -CSSOddClass odd

The HTML report above can be then forwarded to your email using a SMTP client.

Cheers, Paul Wilk
Reply
0 Kudos
raghushetty
Enthusiast
Enthusiast

you can follow this below link and try once this may work.

http://www.riccardoriva.info/blog/?p=1184

Reply
0 Kudos
raghushetty
Enthusiast
Enthusiast

Or you try with this too

Connect-VIServer Servername

$body = Get-Folder foldername | Get-VM | Get-Snapshot | Select Name, VM, SizeMb | Out-String

Send-MailMessage -From "VMware@vmware.com" -To "user@vmware.com" `

  -SmtpServer "name" -Body $body `

  -Subject "Snapshot Report"

from PowerShell you can send email with cmd

Reply
0 Kudos
arvin1201
Contributor
Contributor

hi Pwilk,

Sorry for the late response and Thank you for the script but while running it gives me error of  " Set-Alternating Rows" is not recognized as cmdlet.

Also i am looking with the categories of

VM  | Snapshot name | Description | Created On | Initiated By 

please help.

Reply
0 Kudos
arvin1201
Contributor
Contributor

Hi Raghu

Thank you for the reply, but while running the script getting the below error

Get-Folder        Folder with name 'foldername' was not found using the specified

So, what exactly we can specify under "Get-folder".

Please suggest.

Reply
0 Kudos