I've got the current script that is supposed to log onto vsphere, get all snapshots that are over a week old, and email the results.
Connect-ViServer server
$weekOldSnapshots = (Get-Date).AddDays(-7)
$smtpSrv = "name"
$from = "email"
$to = "email"
$subject = "Snapshot Report"
$body = Get-Snapshot -VM $_ | foreach-object { if($_.Created -gt $weekOldSnapshots){ Select Name, VM, SizeMB}}
$message = new-object Net.Mail.MailMessage($from, $to, $subject, $body)
$smtp = new-object Net.Mail.SMTPclient($smtpSrv)
$smtp.send($message)
When I run this however I'm getting the following error: