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:
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.
This is my code:
$session.Open($sessionOptions) #$files = $session.ListDirectory($remotePath) # Iterate over every transfer $fileInfos = $session.EnumerateRemoteFiles( $fromPath, $Null, [WinSCP.EnumerationOptions]::EnumerateDirectories -bor [WinSCP.EnumerationOptions]::AllDirectories) foreach ($fileInfo in $fileInfos) { if ($fileInfo.IsDirectory) { #TODO } else { $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.