如果资源不存在,以下PowerShell脚本将起作用.
Copy-Item $src_dir $dst_dir$agent_folder -recurse
Run Code Online (Sandbox Code Playgroud)
但如果有资源,它会说:
+ 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
Run Code Online (Sandbox Code Playgroud)
我有什么要添加到命令,以便它将无条件地复制文件?
rer*_*run 162
它有一个-force参数.
i_a*_*orf 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
111014 次 |
| 最近记录: |