cls
$File = 'D:\RUS*.csv'
$Archive = 'D:\Archive'
$log = 'D:\ResultSendFile.txt'
$exe = 'B:\psftp.exe'
$conf = 'B:\upload.ftp'
if(Test-Path $log) { Remove-Item $log }
function SFTP {
"mput $File`nbye" | out-file $conf -force -Encoding ASCII
$p = Start-Process $exe -NoNewWindow -Wait -PassThru -RedirectStandardOutput $log -ArgumentList "-l username -pw password
ftp.server.com -b $conf -v -be"
if(Test-Path $conf) { Remove-Item $conf }
if($p.ExitCode -eq 0) { Copy-Item $File $Archive }
if($p.ExitCode -eq 0) { Remove-Item $File }
}
while ($true) {
if(Test-Path $File) { SFTP }
}