Managing FTP via PowerShell

by Jan 31, 2018

There are no built-in FTP commands in PowerShell, but you can easily download and install a free extension that provides the missing commands. Just run this line:

 
PS> Install-Module -Name Posh-SSH -Scope CurrentUser
 

If PowerShell cannot find the Install-Module command, then you are most likely not using the latest version of PowerShell (5.1). Please update your PowerShell installation, or add the Microsoft’s “PowerShellGet” module which provides the Install-Module command.

The command downloads the Posh-SSH module from the public PowerShell Gallery. Once you approve the download, here are your new commands:

 
PS> Get-Command -Module Posh-SSH 
 
CommandType Name                               Version Source  
----------- ----                               ------- ------  
Function    Get-PoshSSHModVersion              2.0.2   Posh-SSH
Function    Get-SFTPChildItem                  2.0.2   Posh-SSH
Function    Get-SFTPContent                    2.0.2   Posh-SSH
Function    Get-SFTPLocation                   2.0.2   Posh-SSH
Function    Get-SFTPPathAttribute              2.0.2   Posh-SSH
Function    Get-SFTPSession                    2.0.2   Posh-SSH
Function    Get-SSHPortForward                 2.0.2   Posh-SSH
Function    Get-SSHSession                     2.0.2   Posh-SSH
Function    Get-SSHTrustedHost                 2.0.2   Posh-SSH
Function    Invoke-SSHCommand                  2.0.2   Posh-SSH
Function    Invoke-SSHCommandStream            2.0.2   Posh-SSH
Function    Invoke-SSHStreamExpectAction       2.0.2   Posh-SSH
Function    Invoke-SSHStreamExpectSecureAction 2.0.2   Posh-SSH
Function    New-SFTPFileStream                 2.0.2   Posh-SSH
Function    New-SFTPItem                       2.0.2   Posh-SSH
Function    New-SFTPSymlink                    2.0.2   Posh-SSH
Function    New-SSHDynamicPortForward          2.0.2   Posh-SSH
Function    New-SSHLocalPortForward            2.0.2   Posh-SSH
Function    New-SSHRemotePortForward           2.0.2   Posh-SSH
Function    New-SSHShellStream                 2.0.2   Posh-SSH
Function    New-SSHTrustedHost                 2.0.2   Posh-SSH
Function    Remove-SFTPItem                    2.0.2   Posh-SSH
Function    Remove-SFTPSession                 2.0.2   Posh-SSH
Function    Remove-SSHSession                  2.0.2   Posh-SSH
Function    Remove-SSHTrustedHost              2.0.2   Posh-SSH
Function    Rename-SFTPFile                    2.0.2   Posh-SSH
Function    Set-SFTPContent                    2.0.2   Posh-SSH
Function    Set-SFTPLocation                   2.0.2   Posh-SSH
Function    Set-SFTPPathAttribute              2.0.2   Posh-SSH
Function    Start-SSHPortForward               2.0.2   Posh-SSH
Function    Stop-SSHPortForward                2.0.2   Posh-SSH
Function    Test-SFTPPath                      2.0.2   Posh-SSH
Cmdlet      Get-SCPFile                        2.0.2   Posh-SSH
Cmdlet      Get-SCPFolder                      2.0.2   Posh-SSH
Cmdlet      Get-SFTPFile                       2.0.2   Posh-SSH
Cmdlet      New-SFTPSession                    2.0.2   Posh-SSH
Cmdlet      New-SSHSession                     2.0.2   Posh-SSH
Cmdlet      Set-SCPFile                        2.0.2   Posh-SSH
Cmdlet      Set-SCPFolder                      2.0.2   Posh-SSH
Cmdlet      Set-SFTPFile                       2.0.2   Posh-SSH 
 

There is an extensive article on how to use these commands at powershellmagazine.com:http://www.powershellmagazine.com/2014/07/03/posh-ssh-open-source-ssh-powershell-module/

Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this year’s PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at www.psconf.eu.

Twitter This Tip! ReTweet this Tip!