Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Robocopy - Monitor with Email Reporting

Avatar of 00831607020
00831607020 asked on
Microsoft DOSScripting LanguagesPowershell
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
Avatar of larsrohr
larsrohrFlag of United States of America image

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

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers