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