You need to add invoke to the script line:
$session.GetFiles.invoke($SourceFile,$TargetFolder).Check()
Another UPDATE:
This seems to only happen in the situation where the variables are being passed in as parameters to a function.
$SourceFile = "/Extract/SCTM.xlsx"
$TargetFolder = "e:\File-Hold\"
$session.GetFiles($SourceFile,$TargetFolder).Check()
Works fine...
function DOWNLOAD($SourceFile,$TargetFolder)
{
$session.GetFiles($SourceFile,$TargetFolder).Check()
}
DOWNLOAD("/Extract/SCTM.xlsx","e:\File-Hold\")
This on the other hand results in the problem I posted. Where the path for source and destination are combined.
UPDATE:
This is happening on both Powershell 2.0 and 3.0.
Version 5.1.5 of winscp and automation library.
I'm working on a simple download of specific files and I've run into this issue.
This works.
$session.GetFiles("/Extract/SCTM.xlsx","e:\File-Hold\").Check()
This Does not.
$SourceFile = "/Extract/SCTM.xlsx"
$TargetFolder = "e:\File-Hold\"
$session.GetFiles($SourceFile,$TargetFolder).Check()
The problem in the log seems to be that the path doesn't resolve as expected.
> 2013-06-12 11:37:10.120 Script: get -nopermissions -preservetime -transfer="binary" -- "/Extract/SCTM.xlsx e:\File-Hold\" ""
It seems to be adding the 2 paths together as a source file and setting the targetfolder to be blank.
I've tried a lot of different ideas to get the variable paths to work but always comes back incorrect in the logs giving error
Can't get attributes of file '/Extract/SCTM.xlsx e:\File-Hold\'.
Any idea's why this is happening. I'm running the code on a 2012 server running powershell 3.0.