-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get-SFTPItem failing if Path has en dash #524
Comments
@darkoperator please help. thank you! |
You may try to play with $sftp = New-SftpSession .....
$sftp.Session.ConnectionInfo.Encoding = [System.Text.Encoding]::GetEncoding(1252) with your code page of course |
tried this one even changing the encoding but still not working :( |
did a test (with standard dash and unicode from U+2012 to U+2015) |
╭─ pwsh ~ 06:12:52
╰─❯ Get-SFTPChildItem -SessionId 0 -Path "/tmp"
FullName : /tmp/this-is-a-test
LastAccessTime : 4/17/2023 6:11:06 AM
LastWriteTime : 4/17/2023 6:11:39 AM
Length : 4096
UserId : 1000
FullName : /tmp/klippy_uds
LastAccessTime : 4/16/2023 7:38:02 PM
LastWriteTime : 4/16/2023 7:38:02 PM
Length : 0
UserId : 1000
FullName : /tmp/.ICE-unix
LastAccessTime : 4/15/2023 9:17:04 PM
LastWriteTime : 4/15/2023 9:17:04 PM
Length : 4096
UserId : 0
FullName : /tmp/.Test-unix
LastAccessTime : 4/15/2023 9:17:04 PM
LastWriteTime : 4/15/2023 9:17:04 PM
Length : 4096
UserId : 0
FullName : /tmp/printer
LastAccessTime : 4/15/2023 9:24:18 PM
LastWriteTime : 4/15/2023 9:24:18 PM
Length : 10
UserId : 1000
FullName : /tmp/.font-unix
LastAccessTime : 4/15/2023 9:17:04 PM
LastWriteTime : 4/15/2023 9:17:04 PM
Length : 4096
UserId : 0
FullName : /tmp/systemd-private-88a2db33291e4d6abfdad0fead8d28b3-systemd-timesyncd.service-16ATfW
LastAccessTime : 4/15/2023 9:17:04 PM
LastWriteTime : 4/15/2023 9:17:04 PM
Length : 4096
UserId : 0
FullName : /tmp/klipper_host_mcu
LastAccessTime : 4/16/2023 7:38:01 PM
LastWriteTime : 4/16/2023 7:38:01 PM
Length : 10
UserId : 0
FullName : /tmp/.XIM-unix
LastAccessTime : 4/15/2023 9:17:04 PM
LastWriteTime : 4/15/2023 9:17:04 PM
Length : 4096
UserId : 0
FullName : /tmp/.X11-unix
LastAccessTime : 4/15/2023 9:17:04 PM
LastWriteTime : 4/15/2023 9:24:17 PM
Length : 4096
UserId : 0
FullName : /tmp/.X0-lock
LastAccessTime : 4/15/2023 9:24:17 PM
LastWriteTime : 4/15/2023 9:24:17 PM
Length : 11
UserId : 0
╭─ pwsh ~ 06:13:25
╰─❯ Get-SFTPItem -SessionId 0 -Path '/tmp/this-is-a-test' -Destination ./ -Verbose
VERBOSE: Downloading /tmp/this-is-a-test/test.txt
╭─ pwsh ~ 06:14:11
╰─❯ ls .\this-is-a-test\
Directory: C:\Users\Carlos Perez\this-is-a-test
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/17/2023 6:14 AM 0 test.txt How are you running the command so I can replicate. |
@darkoperator thank you so much for responding ` $sftpSession = New-SFTPSession -ComputerName $ctnIP -Credential $pscred -KeyFile $keyFile -OperationTimeout -1 -AcceptKey ` I executing this using PowerShell and the value for Path is a parameter and when I tried to list the folders I got this folder name: 20230414 - Spark-ONYX – Dress Rehearsal - ReDrop |
There is a weird character there between Onyx and Dress that PS does not know how to interpret it
|
@darkoperator its an en dash |
It is a different hash from the other ones, I can see it is longer in one screenshot and a weird question mark in the other.
|
@darkoperator using WinSCP here is the folder name |
I think encoding of "en dash" ( – U+2013 ?) in $value not correct |
Hi @MVKozlov tried this but it's not working, it's just getting this so it still returns an error |
I don't like the "-1" in your UserId and Length outputs, it seems like something is wrong with the access or it could be an OS issue. Did you tried |
That looks like a hyphen to me, not a dash. Have you tried converting the filename to Unicode character values to see what that character really is?
*Edited because I should have started at 0 on the string, not 1 |
@MikeMM70 tried it and I got 65533 |
|
There is something really wrong with encoding |
Hi I have a folder from our SFTP server who has en dash in its path and whenever we tried to use the command to download the folder in our local machine it is failing saying that the folder is not existing. Any suggestions or workaround for this?
The text was updated successfully, but these errors were encountered: