New Training: Conquer Common PowerShell Tasks
In this 5-video skill, CBT Nuggets trainer Knox Hutchinson teaches you how to remotely manage computers by using PowerShell remoting (PSRemoting), how to alert yourself when a script fails by using email notifications, and more. Watch this new Microsoft Windows Server training.
Watch the full course: Programming Foundations with PowerShell 7
This training includes:
5 videos
21 minutes of training
You’ll learn these topics in this skill:
Everyday Tasks in PowerShell
Remotely Manage Computers (Even Linux) with PSRemoting
Sending an Email
Kicking Off Jobs
Summarizing Common PowerShell Tasks
How to Send an Email With PowerShell
When automating tasks via scripting with PowerShell, it is useful to be able to send notifications with the completed results of that script. There are multiple ways to send notifications via PowerShell. One of the easiest, and most useful, ways to send a message is through email.
To send an email through PowerShell use the Send-MailMessage cmdlet. This cmdlet contains 17 flags. For more information regarding each of these flags, visit the documentation page for the Send-MailMessage cmdlet.
Sending a message through PowerShell can be straightforward. Here is an example:
Send-MailMessage -From ‘User01 ‘ -To ‘User02 ‘ -Subject ‘Test mail’
In this example, the 'From', 'To', and 'Subject' flags are used. The From flag explains who the email originates from, the To flag expresses where that message is going, and the Subject flag defines the subject of that email.
Additional flags may be required depending on the environment this cmdlet is being used with.
Being able to send an email with PowerShell can be a helpful tool. For example, if a PowerShell script is pulling data from a database, those results could be emailed to a specific person once that task completes.
delivered to your inbox.
By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.