@martin Thank you, this points me in the right direction!
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
Check, evaluate the
Session.PutFilesfor that specific file.
The process cannot access the file because it is being used by another process
$updateFolderis correct as there are say 1000 files in that path, and the random one will be missed from time to time (it is not often at all, but I am try to deal with the error handling).
Add-Type -Path "path to WinSCPnet.dll"
$sessionOptions = New-Object WinSCP.SessionOptions
$session = New-Object WinSCP.Session
$session.PutFiles($updateFolder, "update path").Check()