It is easy to copy multiple files to a folder that does not exist and create it:
Copy-Item C:\Temp\aa C:\Temp2\DoesNotExist
In the above command, the DoNotExist folder will be created. This is what I want.
But what is the PowerShell syntax for it when the source is only one file?
Copy-Item C:\Temp\test.txt C:\Temp2\DoesNotExist
I tried C: \ Temp2 \ DoesNotExist \ (with a trailing slash), but Powershell says, "The file name, directory name, or volume label syntax is incorrect." and refuses to copy one file.
source share