title: PowerShell: Copy-Item Cannot find path
body: <p>I'm trying to get <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="noreferrer">PowerShell</a> to copy files from a remote computer (on which I have admin rights through <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="noreferrer">AD</a>) to the local computer.
  It fails in the strangest place. Here's a snippet of the script:</p>
  
  <pre><code>    $configs = Get-ChildItem -Recurse -ErrorAction SilentlyContinue -Filter "*.config" $serverUNCPath 
  foreach($config in $configs){
      $config_target_dir = $dest.Path + $config.Directory.FullName.Replace($serverUNCPath,"")
      if(Test-Path -Path $config_target_dir){
          Copy-Item $config -Destination  $config_target_dir
      }
  }
  </code></pre>
  
  <p>It fails with the message </p>
  
  <pre><code>Cannot find path 'D:\ServerDeploy\TestMachine1\website\web.config' because it does not exist.
  At :line:39 char:12
  +           Copy-Item &lt;&lt;&lt;&lt;  $config -Destination  $config_target_dir
  </code></pre>
  
  <p>The path <code>D:\ServerDeploy\TestMachine1\website</code> exists. I'm going mad over this.</p>
  
  <p>What can I do to fix it?</p>