Can't find PSFTP repository to report.
Opened this issue · 1 comments
NemoDima commented
I apologize for that writing here.
But can't find a repository for the PSFTP module or any way to report.
Duplicate from the StackOverflow:
I want to download some folders and files from another server via FTP using Powershell PSFTP module.
Following this answer I wrote the next script:
$User = "xxxxx"
$Password = ConvertTo-SecureString "xxxx" -AsPlainText -Force
$Credentials = New-Object System.Management.Automation.PSCredential ($User, $Password)
$ftp_server = "ftp://backup.xxxxx.eu"
$ftp_path = "backup_old/xxx/xx_Config_Backup"
$local_path = "D:\Backup\backup_old\xxx"
Set-FTPConnection -Credentials $Credentials -Server $ftp_server -EnableSsl -ignoreCert -UsePassive
Get-FTPChildItem -path $ftp_path -Recurse | Get-FTPItem -localpath $local_path -Overwrite -Verbose #-RecreateFolders
This script works fine when ftp_path's folder consists of just files.
ContentLength : -1
Headers : {}
SupportsHeaders : True
ResponseUri : ftp://backup.xxxxx.eu/
StatusCode : ClosingData
StatusDescription : 226 Transfer complete.
LastModified : 01.01.0001 0:00:00
BannerMessage : 220 Microsoft FTP Service
WelcomeMessage : 230 User logged in.
ExitMessage : 221 Goodbye.
IsFromCache : False
IsMutuallyAuthenticated : False
ContentType :
VERBOSE: Performing the operation "Download item: 'ftp://backup.xxxxx.eu
/backup_old/xxx/QlikView/xxx.qvw'" on target "".
226 Transfer complete.
VERBOSE: Performing the operation "Download item: 'ftp://backup.xxxxx.eu
/backup_old/xxx/QlikView/xxxFulFillment.qvw'" on target "D:\Backup\backu
p_old\xxx\xxx.qvw".
226 Transfer complete.
But when it consists of additional folders with files, it creates a file with zero-size named same as folder and crashes with 550 error.
ContentLength : -1
Headers : {}
SupportsHeaders : True
ResponseUri : ftp://backup.xxxxx.eu/
StatusCode : ClosingData
StatusDescription : 226 Transfer complete.
LastModified : 01.01.0001 0:00:00
BannerMessage : 220 Microsoft FTP Service
WelcomeMessage : 230 User logged in.
ExitMessage : 221 Goodbye.
IsFromCache : False
IsMutuallyAuthenticated : False
ContentType :
VERBOSE: Performing the operation "Download item: 'ftp://backup.xxxxx.eu
/backup_old/xxx/xx_Config_Backup/AlertSender'" on target "".
Get-FTPItem : Exception calling "GetResponse" with "0" argument(s): "The remote
server returned an error: (550) File unavailable (e.g., file not found, no acc
ess)."
At C:\PS_Scrips\PSFTP_1.ps1:13 char:45
+ ... -Recurse | Get-FTPItem -localpath $local_path -Overwrite -Verbose #- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,Get-FTPItem
Could you help me please understand the cause of the problem and fix it?
Thanks.
NemoDima commented
Get-FTPChildItem -path $ftp_path -Recurse | Where-Object { $_.Dir -ne "DIR" } | Get-FTPItem -localpath $local_path -Overwrite -Verbose -RecreateFolders
Solve the problem.