Hi Experts,
Could you please advice on the following. Thank you.
1) Robocopy is having issues deleting the source files after the move. Below is the error. (from Robocopy.log)
ERROR 32 (0x00000020) Deleting Source Directory \server01\Folder1\
The process cannot access the file because it is being used by another process.
2) Also, I am not getting the error email. Am I missing something? (code below)
$SourceFolder1 = "\\server01\Folder1"
$TargetFolder1 = "\\server02\Folder2"
robocopy $SourceFolder1 $TargetFolder1 *.log /XX /Move /LOG+:Robocopy.log
if ($lastexitcode -ne 0)
{
Send-MailMessage -From "alerts@company.com" -To "servicedesk@company.com" -Subject "Automated message: Robo copy failed" -Body "Robocopy failed with exit code: $lastexitcode" -SmtpServer "smtp.company.com"
}