#source1 file location $source1 = "C:usersmedesktop est1" #dest1 file location $dest1 = "C:usersmedesktopfinal" #finds files in $source1 that are the very latest and copies to $dest1 try { Get-ChildItem $source1 -Recurse | Sort-Object -Property CreationTime -Descending | Select-Object -First 1 | Copy-Item -Destination $dest1 -ErrorAction 'Stop' } catch{ $_.Exception.Message | Out-File -FilePath .errorlog.txt -Encoding utf8 }