That worked, thank you!
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
TransferOptionsis the fourth argument of
$session.PutFiles($item, $remotePath, $False, $transferOptions).Check()
Upload of file 'file.xml' was successful, but error occurred while setting the permissions and/or timestamp.
If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
No such file or directory.
Error code: 2
Error message from server (en-US): No such file
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FilePermissions = $Null
$transferOptions.PreserveTimestamp = $False
$session.PutFiles($item, $remotePath, $transferOptions).Check()