SFTP – Sending files and archiving them securely with powershell

I was recently tasked to build a script that is as light as possible but still able to send files via SFTP securely and quickly. This script has error checking and reporting, and will sleep if the files are not currently available for a set amount of time.

Can you make this script more efficient? Yes, but it will carry more requirements. We needed to be light and simple to allow the best compatibility.

Notes:
– Will detect for default values and files
– Will error locally and via ftp if it can connect
– Waits for file complete.%DATE%.date to signal script that all files are ready to be uploaded
– Uploads all files with specified extension (csv is default)
– Archives processed files, compresses them, and deletes the sources
– Purges old archives after specified time

Source files needed:
– 7z.exe
– psftp.exe

You will also need to create the config.xml file which saves the required information:

PowerShell:

2 comments… add one
  • jre Link Reply

    hey, do you have a twitter?

    • Dylan Link Reply

      I do, its @DylanZeleski (Have not started using it yet), I plan on posting a lot of my daily one liners as well as some other random things I do day to day.

Leave a Comment

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