powershell - 如何告诉 'PowerShell' Copy-Item无条件复制文件

标签 powershell

如果资源不存在,以下 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

我必须在命令中添加什么才能无条件复制文件?

最佳答案

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

关于powershell - 如何告诉 'PowerShell' Copy-Item无条件复制文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1787836/

相关文章:

powershell - 调用-AzureRmResourceAction : The pipeline has been stopped

powershell - 移动项目,但如果发生冲突则保持最新

powershell - 使用 PowerShell 在 Web 应用程序中启用应用程序日志记录

.net - 如何将字符串拆分为不带多个空格的字符串数组

powershell - New-Item改变函数返回值

Powershell AcceptTcpClient() 不能被 Ctrl-C 中断

powershell - 在 powershell 脚本中尝试/捕获 aws cli 错误

powershell - 如何安全读取 PowerShell .PSD1 文件

powershell - 出现错误时跳过部分脚本

xml - Powershell - 将 XML 转换为 CSV