Post a reply

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)


Topic review


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:

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\" `
  /log="C:\writable\path\to\log\WinSCP.log" /ini=nul `
  /command `
    "open sftp:// (removed by poster)
    "Put C:\Test\*.*"  `
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
  Write-Host "Success"
  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...
Using username xxxx
Authenticating with pre-entered password.
Starting the session...
Session started.
Active session: [1] xxxx

Any thoughts on what I did wrong?