Just modify your existing
powershell.exe
command-line in the batch file.
powershell.exe
command-line in the batch file.
I thought we were trying to determine why we do not return to the batch file after the script completes. If that is not of interest, we'll just drop it.
powershell .... > output.txt 2>&1
Write-Host
. I've asked for that output.
finally { }
! You want to move the files on success only. So, for example after Write-Host "Done, downloaded $count files."
.
param (
# Use Generate Session URL function to obtain a value for -sessionUrl parameter.
$sessionUrl = "sftp://user:mypassword;fingerprint=ssh-rsa-xx-xx-xx@example.com/",
[Parameter(Mandatory = $True)]
$localPath,
[Parameter(Mandatory = $True)]
$remotePath,
[Parameter(Mandatory = $False)]
$finalDir,
[Parameter(Mandatory = $True)]
$listPath,
$sessionLogPath = $Null,
[Switch]
$pause
)
finally
{
# Disconnect, clean up
$session.Dispose()
# Move downloads to the finalDir from parameters
if ($finalDir) {
Move-Item -Path $localPath\* -Destination $finalDir
}
}
downloadNewFiles.ps1
does. Does it do any logging/progress output? What output do you get, when you execute the batch file? And once you have everything in PowerShell script, you better do the move in the PowerShell script too.
@echo off
:Start
REM download new data from <location>
powershell.exe -File C:/dtl_ftp/bin/downloadNewFiles.ps1 -sessionURL "sftp://username:password;fingerprint=ssh-rsa redacted=@IP:port/" -localPath "C:/dtl_ftp/Temp/folder/ -remotePath "/" -listPath "c:\dtl_ftp\conf\location_downloaded.txt" -sessionLogPath "C:\dtl_ftp\logs\log.log"
REM push to active folder
move c:\dtl_ftp\Temp\folder\*.* c:\dtl_ftp\Dowloads\folder
:Done
exit