Script Center > Scripting Forums > The Official Scripting Guys Forum! > Powershell Copy command overwrites files by default
Ask a questionAsk a question
 

AnswerPowershell Copy command overwrites files by default

Answers

  • Wednesday, November 04, 2009 12:42 AMDan Holton Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    No.
    get-help copy-item -full
    shows that there aren't any parameters to prevent the overwriting of a file that already exists. 

    Typically what I'll do is use use a loop with "test-path" (returns true/false) to determine if the file already exists...

    -Dan Holton

All Replies

  • Wednesday, November 04, 2009 12:42 AMDan Holton Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    No.
    get-help copy-item -full
    shows that there aren't any parameters to prevent the overwriting of a file that already exists. 

    Typically what I'll do is use use a loop with "test-path" (returns true/false) to determine if the file already exists...

    -Dan Holton