programing

'PowerShell'Copy-Item에 무조건 파일 복사를 지시하는 방법

nasanasas 2020. 10. 23. 07:58
반응형

'PowerShell'Copy-Item에 무조건 파일 복사를 지시하는 방법


다음 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매개 변수를.


문서에서 ( 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

참고 URL : https://stackoverflow.com/questions/1787836/how-to-tell-powershell-copy-item-to-unconditionally-copy-files

반응형