Wednesday, 8 December 2010

Send email using PowerShell

I like it when you come across something new and today’s nugget is the PowerShell cmdlet Send-MailMessage.  I’ve used mailing scripts with VBS in the past, for example when I wanted email notification when a script had finished but the beauty of the PowerShell method is that you can do it with a single line of code.  As a bare minimum all you need is something like:

image

Okay, so I did say that you only needed a single line of code but I used the back-tick (highlighted) just to make it more readable.

You can find the TechNet article on the Send-MailMessage cmdlet here.

No comments:

Post a Comment