I try to use powershell to deploy a build (Visual Studio) to multiple remote server. The problem is, that the powershellscript does not copy the folders like I intendet to. I use the following powershell command to copy the published website to the destinations.
Copy-Item -Path D:\Websites\$(ProjectName)\ -Recurse -Destination \\%RemoteServer%\D$\Websites\$(ProjectName)\ -Container -Exclude *.config -force
When the folder on the remoteserver does not exist, everything works fine. But if the folder exists, all files are copied into a new subfolder instead of overwriting the existing ones.
So in the first execution the destination is corrected and looks like this:
D:\Websites\TestWebsite\ {all files}
After a second copy, the destination of the copy is:
D:\Websites\TestWebsite\Publish\ {all files}
The variables ProjectName and RemoteServer are in both executions the same.