send mail on script failure

Hi Friends,

I have a simple script which makes nw connection, copies files from source to destination & closes the connection.

net use \\destinationpath\IPC$ "passwod" /user:domain\username
robocopy "sourcepath" "\\destinationpath" /MIR /IS
net use \\destinationpath\IPC$ /delete

Idea is to get an email if the above script fails in execution, any advise please...
LVL 10
Minesh ShahSharePoint & all about itAsked:
Who is Participating?
ahoffmannConnect With a Mentor Commented:
# a simple web-search returned something like:

$msg = New-Object
$msg.from = "from@me"
$msg.Subject = “Subject:”
$msg.Body = " - - your message here - - "
$smtp = New-Object
$smtp.Host = "FQDN-SMTP-server"  
do you have a CLI mail command?
Minesh ShahSharePoint & all about itAuthor Commented:
Hi Hoffmann,
we use windows servers.
Minesh ShahSharePoint & all about itAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.