Upload file to SFTP using PowerShell
<p>We were asked to set up an automated upload from one of our servers to an SFTP site. There will be a file that is exported from a database to a filer every Monday morning and they want the file to be uploaded to SFTP on Tuesday. The current authentication method we are using is username and password (I believe there was an option to have key file as well but username/password option was chosen).</p>

<p>The way I am envisioning this is to have a script sitting on a server that will be triggered by Windows Task scheduler to run at a specific time (Tuesday) that will grab the file in question upload it to the SFTP and then move it to a different location for backup purposes.</p>

<p>For example:</p>

<ul>
<li><p>Local Directory: <code>C:\FileDump</code></p></li>
<li><p>SFTP Directory: <code>/Outbox/</code></p></li>
<li><p>Backup Directory: <code>C:\Backup</code></p></li>
</ul>

<p>I tried few things at this point WinSCP being one of them as well as <a href="http://www.k-tools.nl/index.php/download-sftp-powershell-snap-in/" rel="noreferrer">SFTP PowerShell Snap-In</a> but nothing has worked for me so far. </p>

<p>This will be running on Windows Server 2012R2.<br>
When I run <code>Get-Host</code> my console host version is 4.0.</p>

<p>Thanks.</p>