PowerShell FTP Client Module

The PSFTP module allow you to connect and manage the contents of ftp account. Module contain set of function to get list of items, download and send files on ftp location.

PSFTP.zip
 
 
 
 
 
4.6 Star
(100)
43,906 times
Add to favorites
Applications
3/27/2018
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Remove-FTPItem Fails when filename has non-standard characters
    3 Posts | Last post June 19, 2018
    • First of all, thanks for the script. It's great!
      
      I have a case where the customer has files with accented characters (e.g. é). The script fails to recognize these characters when using Get-FTPChildItem, thus failing to delete a folder that contains a file whose name has one of these characters. 
      
      After some tweaking to the code, I managed to make it work by changing the following line in Get-FTPChildItem.ps1
      from this:
      [System.IO.StreamReader]$Stream = New-Object System.IO.StreamReader($Response.GetResponseStream(),[System.Text.Encoding]::Default)
      
      To this:
      [System.IO.StreamReader]$Stream = New-Object System.IO.StreamReader($Response.GetResponseStream(),[System.Text.Encoding]::UTF8)
      
      Let us know if you decide to change the code to handle these weird filenames.
      Thanks again!
    • I have the same problem. For example an Umlaut-o (ö) in a filename comes as 'ö', via Get_FTPChildItem.
      
      I tried your fix - but it still does not work. Any ideas?
      
      By the way, I found another minor bug in this module: If a user name in the file listing returned by the FTP-Server contains an underscore character '_', the regex fails. So the regex part for the user name must contain the underscore: 
      
      ([._@A-Za-z0-9-]+)
      
      Just in case there will be future bug fixes
    • Nestor Jarquin thank you! Your fix helped me to resolve my issue with listing ftp folder in national charset.
  • Add-FTPItem Bug
    1 Posts | Last post June 15, 2018
    • Hi Michal,
      
      While implementing your module, I came across a bug in the Add-FTPItem script. When attempting to upload a file that doesn't exist on my remote server, Add-FTPItem will throw a 550 error. When using the -Verbose flag, it says the file is a directory and tries to list the files. However, setting the -Overwrite flag uploads the file successfully. Then Add-FTPItem correctly identifies the file as a file without the -Overwrite flag.
      
      
  • I have problem using Get-FTPItem
    2 Posts | Last post May 25, 2018
    • First, thanks for this, really, you have made me so happy with that :D
      
      Well, I have a problem with Get-FTPItem, y try to use it, but, it seem that for any reason, the function doesnt make anything. I think thats the problem is that It´s not get the param "LocalPath" well... I dont know how to give you more details...
      
      hope help
      Thanks!!!
    • The solution is to add the -UseBinary and -KeepAlive to the Set-FtpConnection call.
  • Get-FTPChildItem fails
    2 Posts | Last post May 22, 2018
    • Hello Michal,
      thank you for the great  library. It´s like a mystery,but it runs fine on one computer
      at one location and on another pc on a different location 
      
         $Files_toread1 = Get-FTPchilditem -Path ($FTP_CAM1) -Session $Session
      
      fails like this:
      
         Parent: ftp://xxxxx.hostyyy.eu/16GB_STICK/FIxyzP_00626E6C4142/record
      
      Dir Right     Ln  User   Group  Size   ModifiedDate        Name                                                                 
      --- -----     --  ----   -----  ----   ------------        ----                                                                 
      -                               B                                                                                               
      -                               B                                                                                               
      -                               B                                                                                               
      -                               B  
      .....
      
      that means, no file-objects are read, only "B" for size, nothing else.
      Normally, each line holds one file.
      
      What´s wrong ?
      
      Thanks for reply !
      L.
      
      
      
    • Hi, did you find a fix ?
      I have the same issue.
      
      Cheers
      Aidey
  • Issue after latest MS patches ...
    1 Posts | Last post May 21, 2018
    • Hi All,
      
      I'm experiencing issues
      I've tried the same script across Windows 10 and 2008 / 2012 / 2016 Servers
      
      Window 10 ... (1803 + fully patched)
      Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (504) Gateway Timeout."
      
      Windows 2008 ... (Fully MS patched)
      Works when I try to upload a file (Fully patched)
      
      Windows 2012 ... (Fully MS patched)
      Exception calling "GetRequestStream" with "0" argument(s): "The requested FTP command is not supported when using HTTP proxy."
      
      Windows 2016 ... (Fully MS patched)
      Add-FTPItem : Exception calling "GetRequestStream" with "0" argument(s): "The requested FTP command is not supported when using HTTP proxy."
      
      Any ideas on how to get it to work in Windows 10, 2012 or 2016 ?
      (Module PSFTP is on all devices and loads correctly)
      
      Import-Module PSFTP
      clear-host
      $username = "userid"
      $pass = "password!"
      $password = $pass | ConvertTo-SecureString -asPlainText -Force
      $credentials = New-Object System.Management.Automation.PSCredential($username, $password)
      
      Set-FTPConnection -Credential $credentials -Server 'ftp://remoteserver.name/' -Session MyTestSession -UsePassive
      $Session = Get-FTPConnection -Session MyTestSession
      
      $homedir = "C:\Reports" #we specify the directory where all files that we want to upload 
      $remote = "ftp://remoteserver.name/" #ftp server
      
      #Get-FTPChildItem -Session $Session -Recurse -Verbose #-Depth 2 
      
      
      "Test File" | Out-File TestFile.txt
      Add-FTPItem -Session MyTestSession -Path / -LocalPath TestFile.txt -overwrite 
  • BufferSize issue
    2 Posts | Last post February 07, 2018
    • Just downloaded the latest version and somehow the $BufferSize variable in Get-FTPItem is being set to 1 despite the default value of 20KB or passing in a value.  This results in extremely slow file transfers timeouts when using Get-FTPItem.  Replacing the $BufferSize variable with 20480 (which is what it should be set to anyway?!) and it works fine.
      
      [Byte[]]$Buffer = New-Object Byte[] $BufferSize
      to
      [Byte[]]$Buffer = New-Object Byte[] 20480
      
      The same section of code to instantiate the buffer works ok in isolation.  Very strange issue.
    • Alexander, thank you for posting this discovery. It really saved the day for me. 
      
      This also affects the Add-FTPItem.ps1 file as well. I was trying to send files and they were taking a long time, so I changed Line 59 from:
      
      [Int]$BufferSize = 20KB
      
      to:
      
      [Int]$BufferSize = 20480
      
      This resolved my slow uploads. Hope this helps someone else.
  • Issues when FTP'ing to Azure - 503 error randomly
    1 Posts | Last post February 06, 2018
    • Hi,
      
      Firstly, can I say this is a great library - I've been using if for a while, but I am now suffering an issue with ftp'ing files to an Azure web app.
      
      When trying to send a file I get:
      VERBOSE: Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (530) Not logged in."
      Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (530) Not logged in."
      
      This is after a successful login:
      ContentLength           : -1
      Headers                 : {}
      SupportsHeaders         : True
      ResponseUri             : ftp://xxxx.ftp.azurewebsites.windows.net/
      StatusCode              : ClosingData
      StatusDescription       : 226 Transfer complete.
                                
      LastModified            : 01/01/0001 00:00:00
      BannerMessage           : 220 Microsoft FTP Service
                                
      WelcomeMessage          : 230 User logged in.
                                
      ExitMessage             : 221 Goodbye.
                                
      IsFromCache             : False
      IsMutuallyAuthenticated : False
      ContentType             : 
      
      226 Transfer complete.
      
      
      Quite often fails sending a few files - if I add in a 5 second pause between file transfers the issue is lessened.
      
      I can easily FTP files using FileZilla but not when using your library - is there a way to make it retry a file copy upon first failure, or for it to check that the account I am using is still logged in between transfers?
      
      I am at a loss otherwise to understand why it is not working properly and any help you can offer will be much appreciated.
      
      Thanks
      
  • Issue while uploading file through FTP using PSFTP module
    1 Posts | Last post January 15, 2018
    • Hi Guys,
      
      I am facing a issue while trying to upload a file through FTP using PSFTP module which i have highlighted below.  From the error i can find that the FTP location is considering both the source and destination path. I am not sure how to fix this issue. Can someone help me with this.
      
      Code:
      
      Import-Module PSFTP 
      Set-FTPConnection -Credentials username -Server ftp://servername.com -Session MyTestSession
      $FTP = "ftp://servername.com"
      $FTPPath = "C:\Users\username\Desktop\Scripts\FTP\testfile.txt"
      Add-FTPItem -Path $FTP -LocalPath $FTPPath -Session MyTestSession -Verbose
      
      Error output after the FTP connection is established:
      
      VERBOSE: Performing the operation "Send item: 'C:\Users\username\Desktop\Scripts\FTP\testfile.txt' in ftp location" on target "ftp://servername.com/C:/Users/username/Desktop/Scripts/FTP/testfile.txt".
      Add-FTPItem : Exception calling "GetRequestStream" with "0" argument(s): "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)."
      At line:5 char:1
      + Add-FTPItem -Path $FTP -LocalPath $FTPPath -Session MyTestSession -Ve ...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
          + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Add-FTPItem
      Regards
      
      Sathish
  • Awesome module! Can I contribute?
    1 Posts | Last post December 28, 2017
    • Hello Michal! Awesome module and one of the best (if not the only one) that seem to be able to support a lot of things that I was looking for. However, I was wondering if there is a github repository where I can also make contributions and add some functionality that might be useful for others as well.
      
  • Does this module work on SFTP?
    1 Posts | Last post December 13, 2017
    • Does anybody knows if this module also works for SFTP? if so, what is the syntax to call? Thanks!
1 - 10 of 164 Items