VMware Cloud Community
qwer11121
Contributor
Contributor

How to send a mail after delete a snapshot?

I wrote a powershell script to delete snapshot of VM on ESXi 5.0 every 2 weeks, and I want to get a mail to let me know if the operation was successful. How can I do this?

( I know I can check the task to know the result, but I prefer a e-mail. The vcenter is 5.0 )

Thanks very much.

Tags (2)
Reply
0 Kudos
2 Replies
JarryG
Expert
Expert

Just a tip: check ghettoVCB backup script. I remember it can run from cron and even send mails with backup-logs. It is plain-text script, so you can learn how it sends e-mails and use the same method in your script...

_____________________________________________ If you found my answer useful please do *not* mark it as "correct" or "helpful". It is hard to pretend being noob with all those points! :winking_face:
Reply
0 Kudos
Gav0
Hot Shot
Hot Shot


You could append something like this to your existing script:

Send-MailMessage -from SnapshotScript@yourcompany.com -to you@yourcompany.com -subject "Snapshots Deleted Notification" -body "insert message here" -smtpServer 192.168.0.100

if there is an onscreen output from you script that you want to include in the body of the message you could define your current script as a vairable and have that variable as the body of the email such as:

$deleted_snapshots = yourcurrentcode

Send-MailMessage -from SnapshotScript@yourcompany.com -to you@yourcompany.com -subject "Snapshots Deleted Notification" -body $deleted_snapshots -smtpServer 192.168.0.100

Please award points to your peers for any correct or helpful answers
Reply
0 Kudos