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


Of course! Should have spotted that :(

Thanks a lot Martin.

So that's good.
I can see the real problem now:
You do not pass a path to the source file. You pass $fileInfo object (what converts to a mere filename, by an implicit call to .ToString).
Use $fileInfo.FullName.

The documentation also says this:
The name must be included or the target page has to end with a slash

I have set the value of $toPath to this:
$toPath = "/DataWarehouse/Dev/"

Noting that the trailing slash is included.

The exact error description is:
"Error moving file 'AMPS_Transactions.xlsx' to '/DataWarehouse/Dev/AMPS_Tr


Which would indicate to me that the $toPath variable is correct.[/quote]

Re: Permission denied using MoveFile method

The second argument of Session.MoveFile is:

Full path to new location and name to move/rename the file to.

What $toPath hardly is, as you use the same same value for all files.

Permission denied using MoveFile method

I have created a simple Powershell script to move files from one location to another on the same server.
This is my code:

        #$files = $session.ListDirectory($remotePath)

        # Iterate over every transfer
        $fileInfos =
                [WinSCP.EnumerationOptions]::EnumerateDirectories -bor

        foreach ($fileInfo in $fileInfos)
            if ($fileInfo.IsDirectory)
                $session.MoveFile($fileInfo, $toPath)

On executing the code I get a Permission denied error.
I have verified the user has the required permissions by performing the same move operation from the WinSCP GUI, so I don't know why I am getting this error when using the script.
Grateful if someone can provide advice on this.