WinSCP Not Applying ReplaceInvalidChars Transfer Option Via PowerShell Script

Advertisement

Clyde91
Joined:
Posts:
2
Location:
United States of America

WinSCP Not Applying ReplaceInvalidChars Transfer Option Via PowerShell Script

Hello,
Firstly I would like to thank you for providing such a useful application. While I am having an issue with my script currently, I am finding WinSCP very useful.

My issue is that while syncing a fileshare with Box.com via WinSCP using a powershell script, I find that the script is not applying the ReplaceInvalidChars transfer option to what appears to be only the directories. If the directory does not have invalid characters yet the filename does, ReplaceInvalidChars transfer option works correctly. This does however work on both directories and filenames from GUI. My configuration is as follows:
WinSCP Version: 5.15.1 (Build 9407)
Windows Version: Server 2016
Transfer Protocol: FTPS
Transfer method: PowerShell script
Errors encounter: Log file attached
Script: attached

As this works from GUI but not my script, I am sure my script is the culprit. I am not great with powershell, and less than literate when it comes to .NET, so any assistance would be greatly appreciated.

Regards,
Clyde
Description: Script being used...dont laugh too hard
Description: snippet of WinSCP log where problem presents itself

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
34,115
Location:
Prague, Czechia

Re: WinSCP Not Applying ReplaceInvalidChars Transfer Option Via PowerShell Script

The ReplaceInvalidChars affects only the files and folders created during the transfer. While you are creating the folder with the quote yourself in your code (using the New-Item cmdlet). I actually wonder how come the New-Item cmdlet does not fail and does not stop your script.

The RemotePath.TranslateRemotePathToLocal method does not do the replacement (it does not even have an access to the TransferOptions). This might be improved. I'll see if more people have this problem.

Reply with quote

Clyde91

WinSCP Not Applying ReplaceInvalidChars Transfer Option Via PowerShell Script

Thanks for the insight Martin. My intent was to add some error handling and recovery based on script demonstrated in WinSCP documentation. I will go with a more direct script for the time being in order to make use of the ReplaceInvalidChars option and work on a different method for error handling and recovery.

Reply with quote

Advertisement

You can post new topics in this forum