We help IT Professionals succeed at work.

email alert after task scheduler execute a script.

I have a ps script to backup a server and i scheduled it via task scheduler to run. The script runs and backup works as I expected. I would like to modify the script for me to send an alert after the execution of the script. I do not care whether it is a successful backup or the backup ha failed. I only want to remind you the script ran on this day and time. I will appreciate it if you could list a statement so I can put that at the end of my script.
Watch Question

Most Valuable Expert 2019
Most Valuable Expert 2018
All you need is the Send-MailMessage cmdlet, for example like that:
$sendMailArgs = @{
	From =			'backup@domain.com'
	To =			'someone@domain.com'
	Subject =		"Backup on $($env:ComputerName)"
	SmtpServer =	'smtp.domain.com'
	Body =			"Backup on $($env:ComputerName) was executed by a Scheduled Task."

Send-MailMessage @sendMailArgs

Open in new window

Shaun VermaakSenior Consultant
Awarded 2017
Distinguished Expert 2019

Or call a tool like Blat at the end of the script