troubleshooting Question

Robocopy - Monitor with Email Reporting

Avatar of 00831607020
00831607020 asked on
Scripting LanguagesPowershellMicrosoft DOS
3 Comments1 Solution1069 ViewsLast Modified:
I have a server in NY and one in London.
I have set up a folder in NY so when a user drops a file into it, it moves it to a folder on the server in London. I have done this using Robocopy and I am  happy with it.
It is using the MOT switch and is constantly running.

I would like to add some kind of email functionality so that when a file has been sucessfully copied a notification is sent to specified users.

I have managed to do this with a batch file running a single Robocopy instance and calling a PowerShell command after. But as this works by running after robocopy it does not suit my needs. I need it to run after a file has been succesffuly copied

I run this batch file
-----------------------------------------------------
Robocopy "\\NYServer\Folder1" "\\LondonSever\Folder1" /E /Z /MOT:2 /MOVE /R:20"

Powershell.exe C:\Robocopy\Email.ps1
-------------------------------------------------------




This is  Powershell Email.ps1
-------------------------------------------------------
$emailFrom ="user@domain.co.uk"

$emailTo = "user@domain.co.uk"

$subject = "Test"

$body = "New file in folder"

$smtpserver = "smtp.domain.co.uk"

$smtp = new-object Net.Mail.smtpClient($smtpServer)

$smtp.send($emailfrom, $emailTo, $subject, $body)


 I hope this is enough information for you to help me.




ASKER CERTIFIED SOLUTION
larsrohr

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros