title: Powershell Copy-Item but only copy changed files
body: <p>I am trying to recurse through a directory and copy it from A to B. That can be done with the following:</p>
  
  <pre><code>Copy-Item C:\MyTest C:\MyTest2 –recurse
  </code></pre>
  
  <p>I want to be able though to only copy new files (ones that exist in src but not dest) and also only copy files that may have changed based off a CRC check and not a datetime stamp.</p>
  
  <pre><code>$file = "c:\scripts"
  param
  (
  $file
  )
  
  $algo = [System.Security.Cryptography.HashAlgorithm]::Create("MD5")
  $stream = New-Object System.IO.FileStream($file, [System.IO.FileMode]::Open)
  
  $md5StringBuilder = New-Object System.Text.StringBuilder
  $algo.ComputeHash($stream) | `
  % { [void] $md5StringBuilder.Append($_.ToString("x2")) }
  $md5StringBuilder.ToString()
  
  $stream.Dispose() 
  </code></pre>
  
  <p>This code gives me a CRC check on a specific file...I am just not sure how to put the two scripts together to really give me what I need. I also don't know if the CRC check above is actually the correct way of doing this.</p>
  
  <p>Does anyone have any insight?</p>