tags:

views:

115

answers:

2

This Powershell script:

  Copy-Item $src_dir $dst_dir$agent_folder -recurse

works if the resources are not there. But if the resources are there, it will say:

+   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

What do I have to add to the command so that it will unconditionally copy the files?

+2  A: 

it has a -force parameter

rerun
Thank you. That was easy.
ShaChris23
No "Use the -Force" jokes?
Robert
+1  A: 

From the documentation (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
jeffamaphone