title: powershell | Copy-Item from a CSV list of File Names, Log in that same CSV
body: <p>Good Day Powershell Users</p>
  
  <p>I have a simple script that reads a CSV with a single column filename list (first line <strong>header</strong> called <strong>name</strong>, list names with no extension) and then search for them in a source path, after that it copies those files to another destination path.</p>
  
  <p>CSV Example</p>
  
  <pre><code>Name
  FV_2017_12_161207
  FV_2017_12_161208
  FV_2017_12_161209
  FV_2017_12_161210
  .
  .
  .
  </code></pre>
  
  <p>It works fine but for the sake of keeping a record in case a file doesn't exists i added a Start-Transcript/Stop-Transcript with a TXT file.</p>
  
  <p>This is my code:</p>
  
  <pre><code>$source = "\\192.168.1.3\anexos\"
  $endpath = ".\seleccion\"
  $LogFile = "errorlog.txt"
  Start-Transcript -path $LogFile -append
  Import-Csv list.csv | ForEach-Object {
      Copy-Item $source$($_.name).pdf $endpath
  }
  Stop-Transcript
  </code></pre>
  
  <p>It does the Job but i want to go a little further.</p>
  
  <p>Is there a way to write in the same CSV list for each line if the file was successfully copied or not?</p>
  
  <p>CSV Example</p>
  
  <pre><code>Name               Copy
  FV_2017_12_161207  Ok
  FV_2017_12_161208  Fail
  FV_2017_12_161209  Fail
  FV_2017_12_161211  Ok
  FV_2017_12_161212  Ok
  FV_2017_12_161213  Ok
  .
  .
  .
  </code></pre>
  
  <p>Any help and tips to improve my humble code is greatly appreciated, thank you!</p>