Upload file with date stamp to SFTP

This topic contains 2 replies, has 3 voices, and was last updated by  Chrille 10 months, 3 weeks ago.

  • Author
    Posts
  • #59286

    Luis Garza
    Participant

    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!

  • #59289

    random commandline
    Participant
  • #59314

    Chrille
    Participant

    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.

You must be logged in to reply to this topic.