Hi,
I've startet to script some basic things. The commands work fine, but I've trouble to get the output of the command a mailbody.
Here is my script:
Connect-VIServer -Server "vcentername" - Protocol https -User "username" - Password "userpassword"
$snap = Get-VM | Get-Snapshot | Select VM, SizeMB
$smtpServer = "mymailhost"
$smtpFrom = "sendermailadress"
$smtpTo = "recipientmailadress"
$messagesubject = "Snapoverview"
$messagebody = $snap
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($smtpFrom, $smtpTo, $messagesubject, $messagebody)
I got a mail and the subject is correct but I don't have a body in the mail.
Any ideas?
Kind regards
Patrick