如果资源不存在,则以下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我必须向命令添加什么,才能使它无条件地复制文件?
发布于 2009-11-24 12:47:15
它有一个-force参数。
发布于 2009-11-24 12:48:39
从文档(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? falsehttps://stackoverflow.com/questions/1787836
复制相似问题