Of course I know what you are thinking, ??? Why
would you send an email if email was down? ??? or perhaps you are thinking, ??? Isn ??™ t that just like sending
an email to the users to let them know that they can ??™ t get to their email? ??? Most likely you would send the
email through a separate system, perhaps even to a mobile device through text messages.
Sending an email through PowerShell is pretty straightforward to those familiar with the .NET
Framework. To be able to create a new SMTPClient object you use the New-Object cmdlet and specify
the name of the class used to create the object. After creating the $smtp object, the Send method can be
used with specific parameters called overloads to specify the information needed to send an email. The
following lines of a PowerShell script are all you need to send a message:
$smtpServer = ???relay.exchangeexchange.local???
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send(???fromaddress@exchangeexchange.com???,???administrators@exchangeexchange
.com???,???Message Subject???,???Message body is typed here???)
In this example the sender, recipient, message subject, and body are all set to a specific string. You can
make this code snippet a little more sophisticated by putting variables in place so that you can send the
error message or even the report directly from PowerShell using a script.
Pages:
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654