I used the Copy-Item
command to copy a set reports to a server location. It was working fine before but recently more reports have been added to the folder and now most of the times it works fine but in some cases it shows the error:
The target file "$destination" is a directory, not a file
The code I used is:
Copy-Item -Path "$Source" -Destination "$destination" -Recurse -Force
I am not sure why I am not getting this error for every case.
What you have should work but this may work around the issue if there is some limitation with certain shared folder destinations:
Basically, this enumerates all of the files and folders under the
$Source
directory, then copies the files or folders individually to the destination.If you are able to offer the values of
$Source
and$Destination
I or another might be able to offer a solution to your problem, rather than a workaround.