Author Posts

December 2, 2016 at 10:21 pm

I am new to PowerShell and I would like to be able to upload a file into a SFTP. I manually upload this file each morning and retrieve the results later in the date. The upload file is tricky because it has a date stamp, examples file_name_20161125, file_name_20161201, file_name_20161202. Below is what I have researched online and found in order to start this project.

# Get Date in order to find out date stamp
$date = Get-Date -UFormat "%Y%m%d"

# File location and name
$locPath = "V:\Prod"
$locFileName = "file_name_"
$locExtension = ".csv"
$locUploadName = $locPath + $locFileName + $date + $locExtension

# FTP server information
$Username = "username"
$Password = "password"
$RemoteFile = "ftp://abc.dfg.com"

Thank you so much!

December 3, 2016 at 9:53 pm

I am pretty new to PowerShell too, but I solved a similar task with my favorite free SFTP client WinSCP (https://winscp.net/).
They have a .NET Assembly that you can use with PowerShell. But I recently found a "WinSCP PowerShell Wrapper Module" (http://dotps1.github.io/WinSCP) that will make it even easier.