-
Notifications
You must be signed in to change notification settings - Fork 224
Open
Description
I’m having filename encoding issues when listing files from an SFTP server that use a non-UTF-8 encoding (Nordic letters äöå get replaced with �).
I attempted this workaround:
$SFTPSession = New-SFTPSession -ComputerName x.x.x.x -Port 22 -Credential $Credentials -Verbose
$SFTPSession.Session.ConnectionInfo.Encoding = [System.Text.Encoding]::GetEncoding("ISO-8859-1")
Get-SFTPChildItem -SessionId $SFTPSession.SessionId -Recurse -File
Setting Session.ConnectionInfo.Encoding after connect did not help.
Is there a supported way to set the SSH.NET ConnectionInfo.Encoding before the session connects (e.g., a parameter to New-SFTPSession)?
If I create the SSH.NET ConnectionInfo with Encoding set before connecting, filenames show up correctly.
example
Import-Module Posh-SSH
$enc = [System.Text.Encoding]::GetEncoding("ISO-8859-1")
$auth = New-Object Renci.SshNet.PasswordAuthenticationMethod($user, $pass)
$conn = New-Object Renci.SshNet.ConnectionInfo("x.x.x.x", 22, $user, $auth)
$conn.Encoding = $enc
$sftp = New-Object Renci.SshNet.SftpClient($conn)
$sftp.Connect()
$sftp.ListDirectory("/") | Select-Object Name, FullName
$sftp.Disconnect()
$sftp.Dispose()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels