I'm trying to use Copy-Item to copy a file to an existing folder and getting the error "Could not find part of path". I've Googled this problem for ages, but can't seem to find an answer.
I altered the code to check that I could copy to each folder in the path and then hit the problem when .'s were used in the file name. Also I cannot change the folder name because the folder name is created by a (crappy) Oracle related installer.
Essentially the code is like this (the code is run in the context of the source directory)...
$Filename = "new.txt"
$Destination = "C:\a\b\c\d\e.f\g\h"
Copy-Item -Path $Filename -Destination $Destination
So this works for folders a,b,c and d, but for folder e.f new.txt is copied to folder d and renamed to e.f (which makes sense) and for folders g and h I get the above error. How do I get Copy-Item to see e.f as a folder?
Cheers,
Matt
Create the directory first: New-Item -Path d:\a\b\c\d\e.f\g\h -type directory