PowerShell - Connect to an SFTP Server

by
Jeremy Canfield |
Updated: August 17 2022
| PowerShell articles
The Posh-SSH module can be used to connect to an SFTP server. You might need to install the Posh-SSH module.
Install-Module -Name Posh-SSH
Then the following PowerShell script can be used to attempt to connect to the SFTP server. This should generate a prompt for the username and password to connect to the SFTP server.
$server = "server1.example.com"
$SFTPSession = New-SFTPSession -ComputerName $server
If the connection is successful, something like this should be displayed.
cmdlet New-SFTPSession at command pipeline position 1
Supply values for the following parameters:
(Type !? for Help.)
VERBOSE: Set host key for server1.example.com to f1:ef:6:c4:92:64:3f:cc:6d:51:b7:17:65:5a:2e:eb
Did you find this article helpful?
If so, consider buying me a coffee over at