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.
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...
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
