This function permits to copy file to an other directory.
If a file exists with same filename, it will rename the orginal file by using date and copy file to destination.
Error line5, please replace by
if (Test-Path $destination$filename) {
Nice. I just wrote a similar script. I had it rename the existing file at the destination with a datestamp and also since I was copying to multiple remote servers I implemented a ping test. File copy only happens if server is available.