Sending emails with powershell

When automating tasks in powershell notifications are key, luckily this task is made much simpler with powershells “Send-MailMessage” cmdlet.

In a simplistic form you could use a one liner:

But if you plan on calling this often, why not build a simple function to handle all emails.

The function “Mailer” above will take in 3 parameters and use them to send an email to a pre-configured address. This script could easily be extended to allow it to mail a particular person in the event of a particular error.

0 comments… add one

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.