Posted On March 31, 2019

Script to Push Files to Remote SFTP Server

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Script to Push Files to Remote SFTP Server
# 1. Install WINSCP and include it in the %PATH% environmental variables
# 2. Run this script via Task Scheduler (run every minute)

echo off
option batch on
option confirm off
winscp.com /ini=nul /command ^
"open sftp://USERNAME:[email protected]:2222 -hostkey=""ssh-rsa 2048 xx:xx:03:6b:4f:09:4b:95:dc:0d:f1:xx:xx:xx:xx""" "lcd \\SERVER01\SOMETHING" "cd /REMOTE/DIRECTORY" "put -nopermissions -nopreservetime ""*.*""" "exit"
if %errorlevel% neq 0 exit /b %errorlevel%
del \\SERVER01\SOMETHING\*.* /Q

Leave a Reply

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

Related Post

PowerShell: Probe Remote Machine for Its OS Type

function probeOsType($server){ $ping=test-connection $server -count 1 $ttl=$ping.ResponseTimeToLive $osType=switch($ttl){ {$_ -le 64} {"Linux"; break} # MacOs…

Setting Up Python on a Windows Machine

# Install Visual C++ 14choco install vcredist2017 -y# Install Python 3.8choco install python --version=3.8 -y#…

PowerShell: Scheduled Task to Backup Local Files to remote UNC Path

Set Script Execution Policy on Host PS H:\> Set-ExecutionPolicy RemoteSignedExecution Policy ChangeThe execution policy helps…