tomohulk / WinSCP

WinSCP PowerShell Wrapper Module
GNU General Public License v3.0
153 stars 30 forks source link

RawSetting seems not to be taken in New-WinSCPSessionOption #145

Closed BartVerellen closed 1 year ago

BartVerellen commented 1 year ago

Please fill in the following fields, replacing the values inside the brackets {{ }}.

Issue Description

When I try to transfer files all in lowercase, I tried using the RawSetting option via New-WinSCPSessionOption. However it does not work. Files are still being transferred without changing the name to lowercase.

Example

$myCredential = Get-AutomationPSCredential -Name 'SFTP_TESTUSER'

$rawsettings = @{"FileNameCase" = "2"}

$sessionOption = New-WinSCPSessionOption -RawSetting $rawsettings -HostName xx.xx.xx.xx -Credential $myCredential -GiveUpSecurityAndAcceptAnySshHostKey $session = New-WinSCPSession -SessionOption $sessionOption

$transferOptions = New-WinSCPTransferOption -FileMask "|.gif;.jpeg;.jpg;.png;" Sync-WinSCPPath -LocalPath "\c\temp\" -RemotePath "Files/SYNCFOLDER/" -WinSCPSession $session -Mirror -Mode Remote -Criteria Size -TransferOptions $transferOptions

Remove-WinSCPSession

Expected Output

Filenames are send always in lowercase

Actual Output

Filenames are taken from the source, without a change.

WinSCP-PowerShell Version

WinSCP Module 5.21.7.0

Environment

Azure Automation Runbooks -> Powershell 5.1

martinprikryl commented 1 year ago

The FileNameCase is raw "transfer" settings (not "session" settings): https://winscp.net/eng/docs/rawtransfersettings Though it seems that the API of the module does not support raw "transfer" settings.

BartVerellen commented 1 year ago

@martinprikryl , thanks for your reply. So it's not possible to use this functionality? Do you know if there is any other way to achieve this? The destination is case sensitive, so we need to copy all folders and files in lowercase. @tomohulk any chance this feature is added?

tomohulk commented 1 year ago

Ill dig in and see what it will take to get this added.

tomohulk commented 1 year ago

I added the "RawSettings" parameter to the New-WinSCPTransferOption cmdlet. It's just hash table, just like the one on the New-WinSCPSessionOption cmdlet. Looking at that docs I may create 2 new cmdlets New-WinSCPTransferOptionRawSetting and New-WinSCPSessionRawSetting and then you can use those "hash table" builder cmdlets.

If you wanna grab from this repo and see if it works for you and let me know, that would be great. It's on my todo list for this week to get this repo cleaned up and get some kinda CI/CD solution set back up so until I get there, it won't be published.

tomohulk commented 1 year ago

This is has been published for about 2 weeks now, in v5.21.8.5 and v5.21.8.9. Have you had a chance to test it out?

tomohulk commented 1 year ago

Nevermind, looking at my code, this isn't going to work. I apologize, and ill get it updated today.

tomohulk commented 1 year ago

Ok, it forsure works now. Mind you I had to set this up with a local transfer, so im using the Local sync mode. It's kind of a bummer the way the transfer result returns because that doesn't match the actual file name:

image

I'll get this published out to the gallery today. it will be v5.21.8.10. Let me know if you find any bugs.

BartVerellen commented 1 year ago

Hi,

Many thanks for this! I'll check it out next week. Thanks!

With friendly regards, Bart

Op wo 10 mei 2023 om 16:29 schreef Thomas Malkewitz < @.***>:

Closed #145 https://github.com/tomohulk/WinSCP/issues/145 as completed.

— Reply to this email directly, view it on GitHub https://github.com/tomohulk/WinSCP/issues/145#event-9212451030, or unsubscribe https://github.com/notifications/unsubscribe-auth/A55BOAR4R7TZSAXQH2RAIHDXFOQ3RANCNFSM6AAAAAAVC6X444 . You are receiving this because you authored the thread.Message ID: @.***>

BartVerellen commented 10 months ago

Hi Thomas,

Just wanted to inform you that we finally got the time to implement it here. All is working perfectly!

Thanks for your actions!

Op do 11 mei 2023 om 07:44 schreef Bart Verellen @.***>:

Hi,

Many thanks for this! I'll check it out next week. Thanks!

With friendly regards, Bart

Op wo 10 mei 2023 om 16:29 schreef Thomas Malkewitz < @.***>:

Closed #145 https://github.com/tomohulk/WinSCP/issues/145 as completed.

— Reply to this email directly, view it on GitHub https://github.com/tomohulk/WinSCP/issues/145#event-9212451030, or unsubscribe https://github.com/notifications/unsubscribe-auth/A55BOAR4R7TZSAXQH2RAIHDXFOQ3RANCNFSM6AAAAAAVC6X444 . You are receiving this because you authored the thread.Message ID: @.***>