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: Trouble With PowerShell Upload - Cannot

You have to replace the C:\writable\path\to\log\WinSCP.log placeholder with a real path.

Also note that in PowerShell, you should use the WinSCP .NET assembly:
https://winscp.net/eng/docs/library_powershell
deathtron

Trouble With PowerShell Upload - Cannot

Hi Everyone,

I am trying to do a simple sftp upload with poswershell. It looks like my command to transfer the file is not picking up at all. My command looks like this:
& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul `
  /command `
    "open sftp:// (removed by poster)
    "Put C:\Test\*.*"  `
   
    "exit"
 
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}
 
exit $winscpResult

And my output in PowerShell looks like this:
PS C:\> C:\Users\xxxx\Downloads\test_shell.ps1

Error occurred during logging. It's been turned off.
Can't open log file 'C:\writable\path\to\log\WinSCP.log'.

System Error.  Code: 2.

The system cannot find the file specified
Searching for host...
Connecting to host...
Authenticating...
Using username xxxx
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Session started.
Active session: [1] xxxx
exit
Error


Any thoughts on what I did wrong?