Receiving alerts on if a VM has over a given number of snapshots

An article by Alan from Virtu-Al.Net

Last week I was asked if there was an easy way to get an alert once a VM had over a certain number of snapshots, this is a frequent request as it would seam some backup products like to keep snapshoting VMs and note removing them.

There are several ways this could be kicked off, including setting a vCenter Alarm on snapshots and getting it to run a script but in this case it was simple, they wanted to run a scheduled task once a day and get an email listing the VMs that had over x amount of snapshots and the details about the last one created, of course it was a 5 minute script but I thought I would blog it anyway for others to use if they needed it.  Enjoy

 

BTW, its also very easy to get this to work with gmail if you use that as your email provider, just replace the Send-EmailMessage line with the below:

$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“my.email@gmail.com”, “mYpa$$w0rd”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

 

Example email

image

Script

Receiving alerts on if a VM has over a given number of snapshots is a post from: Virtu-Al.
Virtu-Al is one of the authors of VMware vSphere PowerCLI Reference: Automating vSphere Administration”

Buy it now from:
Amazon USA
Amazon UK
Sybex

Be Sociable, Share!
 

Tags: ,

Comments

No comments so far.

  • Leave a Reply
     
    Your gravatar
    Your Name