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: PutFiles() access is denied in powershell but batch and gui works (solution)

As documented:
Full path to upload the file to. When uploading multiple files, the filename in the path should be replaced with operation mask or omitted (path ends with slash).

https://winscp.net/eng/docs/library_session_putfiles
m.w35tin

PutFiles() access is denied in powershell but batch and gui works (solution)

I'm moving from a legacy batch file to a powershell script and ran into an issue when trying to execute $transferResult = $session.PutFiles($localPath, $remotePath), I kept getting access is denied. I triple checked my $sessionOptions and everything was correct. After hours of debugging turns out that I was missing a / in the $remotePath variable...

So this:

$remotePath = "/destinationFolder",

Needed to be this:

$remotePath = "/destinationFolder/",

Hope somebody finds this useful in the future.