Re: .NET assembly in PowerShell – GetFiles – append seems not working
Yes it's "correct". But appending is NOT supported with FTP.
OverwriteMode.Append
is supported with SFTP only:
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 );