Powershell Scripting – Automatic upload files to remote FTP

Yesterday we had a needed, we needed to transfer every n minutes all the xml files located in a folder to a remote ftp location. There’s a lot of ways to do this and some of them include a payment softwares. In our case files were xml created by a SAP server in a Windows enviroment, for this reason we bet for a powershell script solution that we can call using Windows task scheduler

This script uses the WinSCP dll libraries, for this reason first of all we are going to install this light and free software

You’ll find here: https://winscp.net/eng/download.php

How the script works.

1.- The script, moves files from existing folder to a remote ftp site.

2.- After file is uploaded correctly, this  will be moved to a Success folder

3.- If file exists in Ftp or Success folder, this it will be overwrited

4.- If error occurs, this are going to print in an output log file

5.- All this movements with timestamp  will be written in a log

And this is the script that you have to put ins a ps1 file, for example upload_ftp.ps1

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.