If you use RoboCopy in your PowerShell script, you might want to know if everything went well. Besides the log file, you can check the Exit Code as well.

Use below script to create your own status messages based on the exit code returned by RoboCopy.

For more info about the Exit Codes, check this link: http://ss64.com/nt/robocopy-exit.html

#Start RoboCopy!
robocopy $RemoteSourceFolderPath $LocalTargetPath /E /COPYALL /XO /XF desktop.ini /FFT /R:1 /W:1 /MT:12 /ZB /TEE /PURGE /LOG:$LogPath\_AfdelingsDataRoboCopy_$date.log

# Check exit code
If (($LASTEXITCODE -eq 0))
{
    $RoboCopyMessage = "EXITCODE: 0, Succeeded"                
}
elseif (($LASTEXITCODE -gt 0) -and ($LASTEXITCODE -lt 16))
{
    $RoboCopyMessage = "EXITCODE: 1-15, Warning"
}
elseif ($LASTEXITCODE -eq 16)
{
    $RoboCopyMessage = "EXITCODE: 16, Error"
}
else
{
    $RoboCopyMessage = "Robocopy did not run"
}

Write-Host $RoboCopyMessage