我想复制/粘贴所有文件和其他路径中的所有文件夹。
5 月数据为:
temp
Deploiement
foo.xml
bar.xml
Documentation
brute
我阅读了关于 https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.1 的官方文档,我找到了这个例子:
Example 3: Copy directory and contents to a new directory
Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings\Logs" -Recurse
在我的 Jenkins 中,我这样写:
Copy-Item -Path "temp/Deploiement/*" -Destination "Deploy" -Recurse
控制台错误:
Copy-Item : Container cannot be copied onto existing leaf item.
At D:\JenkinsWks\workspace\pic\temp\Scripts\packer.ps1:114 char:2
+ Copy-Item -Path "temp/Deploiement/*" -Destination "Deploy" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (D:\JenkinsWks\w...t\Documentation:String) [Copy-Item], PSArgumentException
+ FullyQualifiedErrorId : CopyContainerItemToLeafError,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : Container cannot be copied onto existing leaf item.
At D:\JenkinsWks\workspace\pic\temp\Scripts\packer.ps1:114 char:2
+ Copy-Item -Path "temp/Deploiement/*" -Destination "Deploy" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (D:\JenkinsWks\w...nt\brute:String) [Copy-Item], PSArgumentException
+ FullyQualifiedErrorId : CopyContainerItemToLeafError,Microsoft.PowerShell.Commands.CopyItemCommand
答案 0 :(得分:0)
if (-Not (Test-Path "Deploy")) {
md -path "Deploy"
}
Copy-Item -Path "temp/Deploiement/*" -Destination "Deploy" -Recurse