Script didn't save the downloaded files correct
I have the following script (PowerShell)
The script does not save the files in the
The three files on the FTP server are:
It makes a file named
Any ideas?
param ( $localPathImport = "C:\application\Data\12345\Import\SAP\PROJEKTE\", $remotePath = "/test/download/*" ) try { # WinSCP .NET assembly laden Add-Type -Path "WinSCPnet.dll" # Session Einstellungen $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = "host.net" UserName = "user_ftp" SshHostKeyFingerprint = "xxx" SshPrivateKeyPath = "C:\application\AddOns\File_upload\ssh\private_key_cust01_new.ppk" } $session = New-Object WinSCP.Session try { # Verbinden $session.Open($sessionOptions) # Download $transferResult = $session.GetFiles($remotePath, $localPath) foreach ($transfer in $transferResult.Transfers) { # Download erfolgt oder Error? if ($transfer.Error -eq $Null) { $zeit = Get-Date >> C:\application\AddOns\File_upload\download_sap_projektstamm_log.txt Write-output "Download von $($transfer.FileName) erfolgt!" >> C:\application\AddOns\File_upload\download_sap_projektstamm_log.txt } else { $zeit = Get-Date >> C:\application\AddOns\File_upload\download_sap_projektstamm_error.txt Write-output "Download von $($transfer.FileName) fehlgeschlagen: $($transfer.Error.Message)" >> C:\application\AddOns\File_upload\download_sap_projektstamm_error.txt } } # löschen aus Verzeichnis $session.RemoveFiles($remotePath) } finally { # Verbindung trennen $session.Dispose() } exit 0 } catch { $zeit = Get-Date >> C:\application\AddOns\File_upload\download_sap_projektstamm_error.txt Write-output "Error: $($_.Exception.Message)" >> C:\application\AddOns\File_upload\download_sap_projektstamm_error.txt exit 1 }
The script does not save the files in the
$localPathImport
.
The three files on the FTP server are:
project0000000000001319 project0000000000001320 project0000000000001321
%22
in the directory, where is the winscp.exe
located. And in this file %22
, the content of the three files are combined.
Any ideas?