programing

'PowerShell' Copy-Item에서 파일을 무조건 복사하도록 지시하려면 어떻게 해야 합니까?

showcode 2023. 4. 25. 23:48
반응형

'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 입니다.

반응형