Thank you for your answer.
Thanks to the session log file I have now seen the error:
I have amended my script
Now it works as expected.
Thank you for your time.
Thanks to the session log file I have now seen the error:
15:47:18.770 Status code: 3, Message: 521, Server: This server does not support operations to modify file attributes., Language:
* 2016-02-03 15:47:18.770 (ETerminal) Permission denied.
* 2016-02-03 15:47:18.770 Error code: 3
* 2016-02-03 15:47:18.770 Error message from server: This server does not support operations to modify file attributes.
. 2016-02-03 15:47:18.770 Asking user:
. 2016-02-03 15:47:18.770 **Upload of file '***********.xml' was successful, but error occurred while setting the permissions and/or timestamp.**
. 2016-02-03 15:47:18.770
. 2016-02-03 15:47:18.770 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option. ("Permission denied.
. 2016-02-03 15:47:18.770 Error code: 3
. 2016-02-03 15:47:18.770 Error message from server: This server does not support operations to modify file attributes.")
< 2016-02-03 15:47:18.770 Script: Upload of file '*************.xml' was successful, but error occurred while setting the permissions and/or timestamp.
< 2016-02-03 15:47:18.770 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
< 2016-02-03 15:47:18.770 Script: Permission denied.
< 2016-02-03 15:47:18.770 Error code: 3
< 2016-02-03 15:47:18.770 Error message from server: This server does not support operations to modify file attributes.
* 2016-02-03 15:47:18.785 (EScpSkipFile) **Upload of file '***************.xml' was successful, but error occurred while setting the permissions and/or timestamp.**
* 2016-02-03 15:47:18.785
* 2016-02-03 15:47:18.785 If the problem persists, turn off setting permissions or preserving timestamp. Alternatively you can turn on 'Ignore permission errors' option.
* 2016-02-03 15:47:18.785 Permission denied.
* 2016-02-03 15:47:18.785 Error code: 3
* 2016-02-03 15:47:18.785 Error message from server: This server does not support operations to modify file attributes.
. 2016-02-03 15:47:18.785 Script: Failed
> 2016-02-03 15:47:19.347 Script: exit
. 2016-02-03 15:47:19.347 Script: Exit code: 1
. 2016-02-03 15:47:19.347 Closing connection.
. 2016-02-03 15:47:19.347 Sending special code: 12
I have amended my script
#transferoptions
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "*.*"
$transferOptions.FilePermissions = $Null # This is default
$transferOptions.PreserveTimestamp = $False
# Upload files, collect results
$transferResult = $session.PutFiles(($localPath + "*.*"), ($remotePath + "*.*"), $False, $transferOptions)
Now it works as expected.
Thank you for your time.