title: Why is Copy-Item overwriting destination files by default?
body: <p>The behaviour I would expect from the code below is:</p>
  <ol>
  <li><p>Grab a list of the files in the source directory.</p>
  </li>
  <li><p>Loop through and copy each file to the backup destination, only if it does not already exist.</p>
  <pre><code>if (!(Test-Path C:\Folder\Destination)) {
     New-Item -ItemType Directory -Force -Path C:\Folder\Destination
  }
  
  $originalfiles = Get-ChildItem -Path  &quot;C:\Folder\Source&quot;
  $originalfiles
  
  foreach ($file in $originalfiles) {
      Write-Host
      Write-Host File Name: -ForegroundColor DarkYellow
      Write-Host $file.Name
      Write-Host File Path: -ForegroundColor DarkYellow
      Write-Host $file.FullName
  
      $src = $file.FullName
      $dest = &quot;C:\Folder\Destination\$($file.Name)&quot;
  
      Copy-Item $src $dest
  }
  </code></pre>
  </li>
  </ol>
  <p>I would have thought that the <code>Copy-Item</code> cmdlet defaults to NOT overwrite, unless you specify the <code>-Force</code> flag. This is the behaviour I have seen in the past when I originally encountered situations where I did want to overwrite.</p>
  <p>Also, I thought it may be the introduction of the <code>foreach</code> loop but I tried the copy command, on it's own, with hardcoded paths for a single file, and it is still the same.</p>
  <p>Should I restart my IDE, or is it a mistake I have overlooked?</p>