.NET assembly in PowerShell – GetFiles – append seems not working
Greetings,
I'm using the WinSCP assembly quite frequently.
Recently I was trying to retrieve some CSV-files from a remote FTP server and append them in one larger CSV-file for further processing.
But it seems the append does not work (yet)?
Perhaps I'm missing something obvious.
I just downloaded and tried the latest available version: 5.19.6
Basically my script looks like this:
I'm using the WinSCP assembly quite frequently.
Recently I was trying to retrieve some CSV-files from a remote FTP server and append them in one larger CSV-file for further processing.
But it seems the append does not work (yet)?
Perhaps I'm missing something obvious.
I just downloaded and tried the latest available version: 5.19.6
Basically my script looks like this:
Add-Type -Path ".\WinSCPnet.dll" $sessionOptions = New-Object WinSCP.SessionOptions $sessionOptions.HostName = "... hostname ..." $sessionOptions.Protocol = [WinSCP.Protocol]::Sftp $sessionOptions.UserName = " ... username ..." $sessionOptions.Password = " ... pwd ... " $sessionOptions.SshHostKeyFingerprint = " ... " $session = New-Object WinScp.Session $session.Open($sessionOptions) $transferOption = New-Object WinSCP.TransferOptions $transferOption.preserveTimestamp = $true $transferOption.TransferMode = [WinSCP.TransferMode]::Ascii $transferOption.OverwriteMode = [WinSCP.OverwriteMode]::Overwrite $transferResult = $session.GetFiles(" ... remotefile#1 ", "c:\temp\localfile.csv" ,$false ,$transferOption ); $transferOption.OverwriteMode = [WinSCP.OverwriteMode]::Append $transferResult = $session.GetFiles(" ... remotefile#2 ", "c:\temp\localfile.csv" ,$false ,$transferOption );