2

I am aware that there is a similar question asked previously but the solutions primarily focus on using WinSCP. I'm fairly new to SFTP and PowerShell as well, and I need help downloading files from an SFTP server onto my application server.

I believe that the Posh-SSH module can help with establishing an SFTP connection, but most code I have seen until now involves uploading files onto the SFTP server, not downloading from... would appreciate any advice!

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Janet
  • 33
  • 1
  • 5

1 Answers1

1

Just use Get-SFTPItem cmdlet (Get-SFTPFile in older versions):

$remotePath = "/remote/path/file.ext"
$localPath = "C:\local\path\file.ext"
Get-SFTPItem -SessionId $sessionId -Path $remotePath -Destination $localPath

WinSCP will work too though:
Download files from SFTP server using PowerShell

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992