VMware Cloud Community
TylerDurden77
Enthusiast
Enthusiast
Jump to solution

Remove snapshot of server and then send a mail to me when the job is finished.

Hi all,

Could someone help me with a script that would do this?

Regards

Tyler

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Is this along the lines of what you are looking for ?

$snaps = Get-VM | Get-Snapshot
Remove-Snapshot -Snapshot $snaps -Confirm:$false

$emailFrom = "from@somedomain.com"
$emailTo = "to@somedomain.com"
$subject
= "All snapshots are removed"
$body = $snaps | select VM,Name,Created,SizeMB | ft -AutoSize | Out-String
$smtpServer
= "smtpserver"
$smtp
= new-object Net.Mail.SmtpClient($smtpServer) $smtp.Send($emailFrom, $emailTo, $subject, $body)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Is this along the lines of what you are looking for ?

$snaps = Get-VM | Get-Snapshot
Remove-Snapshot -Snapshot $snaps -Confirm:$false

$emailFrom = "from@somedomain.com"
$emailTo = "to@somedomain.com"
$subject
= "All snapshots are removed"
$body = $snaps | select VM,Name,Created,SizeMB | ft -AutoSize | Out-String
$smtpServer
= "smtpserver"
$smtp
= new-object Net.Mail.SmtpClient($smtpServer) $smtp.Send($emailFrom, $emailTo, $subject, $body)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
TylerDurden77
Enthusiast
Enthusiast
Jump to solution

Hi Luc,

Exactly what i was looking for.

SuperDuper thanks!!

Regards

Tyler

0 Kudos