• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

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...
0
Minesh Shah
Asked:
Minesh Shah
  • 2
  • 2
2 Solutions
 
ahoffmannCommented:
do you have a CLI mail command?
0
 
Minesh ShahSharePoint & all about itAuthor Commented:
Hi Hoffmann,
we use windows servers.
0
 
ahoffmannCommented:
# a simple web-search returned something like:

$msg = New-Object system.net.mail.mailmessage
$msg.from = "from@me"
$msg.To.add("to@you")
$msg.Subject = “Subject:”
$msg.Body = " - - your message here - - "
$smtp = New-Object system.net.mail.smtpClient
$smtp.Host = "FQDN-SMTP-server"  
$smtp.Send($msg)
0
 
Minesh ShahSharePoint & all about itAuthor Commented:
ok
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now