Topic "WinSCP powershell script can't handle swedish characters"

Author Message
rasmus.hvitfeldt
[View user's profile]

Joined: 2015-11-06
Posts: 4
Hey,

The background:
I want to download files from a SFTP server and the move the downloaded files to another folder on the SFTP server.

What I've done:
I've used the WinSCP powershell module developed by Thomas Malkewitz (https://github.com/dotps1/WinSCP). My script looks like this (I've cut some bits out):

$session = New-WinSCPSession -Credential $Credential -Hostname $server -SshHostKeyFingerprint $SSHKey

Try
{
foreach ($file in (Get-WinSCPItem $session -Path $RemoteRootFolder -Filter *.xml)) {
Receive-WinSCPItem -WinSCPSession $session -Path $file.Name -Destination $ServerPath
}

}
Catch
{
$ErrorMessage = $_.Exception.Message
Send-MailMessage -From xxxx@xxxx.se -To xxxx.xxxx@xxxx.se -Subject "Couldn't copy remote file!" -Body "The error message was $ErrorMessage" -SmtpServer mail-server.xxxx.se
}

Try
{
#Move each file in RemoteRootFolder to RemoteOldFolder
foreach ($file in (Get-WinSCPItem $session -Path $RemoteRootFolder -Filter *.xml)) {
Move-WinSCPItem -WinSCPSession $session -Path $file.Name -Destination $RemoteOldFolder

}

The error:
The error message was Exception calling "MoveFile" with "2" argument(s): "Error moving file '/xxxx/LEG?RD-151011230000.xml' to 'xxxx/xxxx/LEG?RD-151011230000.xml'."

The "?" character is actally an "Å" letter, which WinSCP can't seem to handle. Any ideas how I can solve this?

I've talked to Thomas and he told me to post here. Smile
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
rasmus.hvitfeldt
[View user's profile]

Joined: 2015-11-06
Posts: 4
Hi,

Thank you for your reply.

Here is my attached session log, marked as private.
Session.log (32.66 KB) Private file

Description: (none)

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
WinSCP handles the file name correctly, imo.

So it must be the server. Maybe it does not support UTF-8.

Try setting raw session settings Utf to "0" (off).
http://winscp.net/eng/docs/rawsettings

Use $RawSetting parameter of New-WinSCPSession.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License