首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何告诉'PowerShell‘Copy-Item无条件地复制文件

如何告诉'PowerShell‘Copy-Item无条件地复制文件
EN

Stack Overflow用户
提问于 2009-11-24 12:43:08
回答 2查看 119.7K关注 0票数 84

如果资源不存在,则以下PowerShell脚本可用。

代码语言:javascript
复制
  Copy-Item $src_dir $dst_dir$agent_folder -recurse

但如果有资源,它会说:

代码语言:javascript
复制
+   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

我必须向命令添加什么,才能使它无条件地复制文件?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-11-24 12:47:15

它有一个-force参数。​​​​

票数 170
EN

Stack Overflow用户

发布于 2009-11-24 12:48:39

从文档(help copy-item -full):

代码语言:javascript
复制
-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
票数 19
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1787836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档