Of course! Should have spotted that :(
Thanks a lot Martin.
Thanks a lot Martin.
$fileInfo
object (what converts to a mere filename, by an implicit call to .ToString
).
$fileInfo.FullName
.
The name must be included or the target page has to end with a slash
$toPath = "/DataWarehouse/Dev/"
"Error moving file 'AMPS_Transactions.xlsx' to '/DataWarehouse/Dev/AMPS_Tr
ansactions.xlsx'.
Session.MoveFile
is:
Full path to new location and name to move/rename the file to.
$toPath
hardly is, as you use the same same value for all files.
$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)
}
}