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

Advertisement

m.w35tin
Guest

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.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
29,070
Location:
Prague, Czechia

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

Reply with quote

Advertisement

You can post new topics in this forum