-
Notifications
You must be signed in to change notification settings - Fork 30
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
Send and Receive fails with [
in the file name
#159
Comments
Have your tried using the ConvertTo-WinSCPEscapedString cmdlet to escape the character? https://github.com/tomohulk/WinSCP/wiki/ConvertTo-WinSCPEscapedString |
Thank you for your reply! No, I was not aware of the
Receive-WinSCPItem -WinSCPSession $Session -RemotePath $(ConvertTo-WinSCPEscapedString -FileMask "/home/test[1234.txt") -LocalPath "C:\Files"
Receive-WinSCPItem -WinSCPSession $Session -RemotePath $(ConvertTo-WinSCPEscapedString -FileMask "/home/test[1234].txt") -LocalPath "C:\Files" However, I'm still having trouble with Send-WinSCPItem -WinSCPSession $Session -LocalPath $(ConvertTo-WinSCPEscapedString -FileMask "C:\Files\test[1234.txt") -RemotePath "/home"
<#
Convert-Path : The specified wildcard character pattern is not valid: test[1234.txt
At C:\Program Files\WindowsPowerShell\Modules\WinSCP\6.1.2.0\Public\Send-WinSCPItem.ps1:58 char:38
+ ... lPathValue in (Convert-Path -Path (Resolve-Path -Path $LocalPath))) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Convert-Path], WildcardPatternException
+ FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.ConvertPathCommand
#>
Send-WinSCPItem -WinSCPSession $Session -LocalPath $(ConvertTo-WinSCPEscapedString -FileMask "C:\Files\test[1234].txt") -RemotePath "/home"
<#
No output was produced
#> It seems like the paths are being escaped correctly in each case: ConvertTo-WinSCPEscapedString -FileMask "/home/test[1234.txt"
<#
/home/test[[]1234.txt
#>
ConvertTo-WinSCPEscapedString -FileMask "/home/test[1234].txt"
<#
/home/test[[]1234].txt
#>
ConvertTo-WinSCPEscapedString -FileMask "C:\Files\test[1234.txt"
<#
C:\Files\test[[]1234.txt
#>
ConvertTo-WinSCPEscapedString -FileMask "C:\Files\test[1234].txt"
<#
C:\Files\test[[]1234].txt
#> Thanks again! |
I have to think about this. Basically it trying to resolve the local file path and that will now fail because that local file doesn't technically exist with those escape characters. I think really you should use the File mask on the -RemotePath, because don't need to escape that on the windows local path. |
Issue Description
When the open square bracket (
[
) character appears in a file name, theReceive-WinSCPItem
andSend-WinSCPItem
cmdlets fail to transfer the file.Example
Expected Output
The
Receive-WinSCPItem
andSend-WinSCPItem
cmdlets should be able to transfer a file containing the open square bracket ([
) character.Actual Output
See code block in Example section above.
WinSCP-PowerShell Version
Environment
OS: Windows Server 2019 (x86_64 / AMD64)
PowerShell Version:
Protocol: SFTP
Server: OpenSSH (Debian 12)
The text was updated successfully, but these errors were encountered: