如果没有资源,则以下PowerShell脚本可以正常工作。
Copy-Item $src_dir $dst_dir$agent_folder -recurse
但如果有资源,它会说:
+ Copy-Item <<<< $src_dir $dst_dir$agent_folder -recurse
+ CategoryInfo : ResourceExists: (C:\Users\Pac\Desktop\Agents\Agent0\lib:S
tring) [Copy-Item], IOException
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.CopyItemComm
and
我必须添加什么才能无条件地复制文件?
答案 0 :(得分:152)
它有一个-force
参数。
答案 1 :(得分:18)
来自文档(help copy-item -full
):
-force <SwitchParameter>
Allows cmdlet to override restrictions such as renaming existing files as long as security is not compromised.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false