Skip navigation
FTP using PowerShell

FTP using PowerShell

FTP using PowerShell with an easy to use module.

Q. How can I FTP using PowerShell?

A. PowerShell has full access to .NET methods which has FTP capabilities however there are PowerShell modules available for download which expose these FTP capabilities as easy to use cmdlets. A great example library to use is available at https://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb. Once you extract to your module path, for example C:\WINDOWS\System32\WindowsPowerShell\v1.0\Modules the module can be loaded and used. Below is an example connection to a FTP server and its contents listed.

Import-Module PSFTP

$FTPServer = 'ftp.host.com'
$FTPUsername = 'username'
$FTPPassword = 'password'
$FTPSecurePassword = ConvertTo-SecureString -String $FTPPassword -asPlainText -Force
$FTPCredential = New-Object System.Management.Automation.PSCredential($FTPUsername,$FTPSecurePassword)


Set-FTPConnection -Credentials $FTPCredential -Server $FTPServer -Session MySession -UsePassive 
$Session = Get-FTPConnection -Session MySession 

Get-FTPChildItem -Session $Session -Path /htdocs #-Recurse

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish