Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Help with MS Access to PowerShell FTP download

Please post the WinSCP log.
shenson

Help with MS Access to PowerShell FTP download

I have automated an email in VBA in Access. Now I'm trying to use PowerShell to download a file, from there Access will import it. I have been having through with Downloading it though, it logs in fine, but is having trouble downloading.
This is my VBA call function.
Function FTP2()
    runSendreports = Shell("Powershell.exe -executionpolicy bypass C:\Program Files\Tasks\FTP.ps1")
End Function


I bypassed that and just tested it with PowerShell and turned on WinSCP logs
& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul `
  /command `
    "open sftp://root:root@192.16x.x.xx/ -hostkey=`"`"ssh-ed519 255 TS/UKKyryg2jo0WN`"`" -rawsettings FSProtocol=2" `
    "cd /usr/share/astguiclient/Scripts" `
    "lcd C:\Shared\BPFilesIn" `
    "get tbl_export.xlsx" `
    "exit"
 
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}
 
exit $winscpResult

From the logs it looks like it logs in, does that hand shake at least, the download doesn't work.