title: Copy files from one remote server to another remote server with Powershell
body: <p>I'm trying to copy files from serverA to serverB using Powershell. Both servers belong to our hosting provider so copying files from A to B is very fast compared to copying files from my local box to either server.
  I figured I could use Powershell to run a remote command on serverA and copy the files to serverB. This is what I came up with:</p>
  
  <pre><code>$SourceServerName = "serverA"
  $SourceContentPath = "\\serverA\c$\testSrc"
  $DestinationContentPath = "\\serverB\c$\testDest"
  
  Invoke-Command -ComputerName $SourceServerName -ScriptBlock {param ($SourcePath,$InstallPath) 
                  Copy-Item -Path $SourcePath\* -Destination $InstallPath -Recurse
              } -ArgumentList $SourceContentPath, $DestinationContentPath
  </code></pre>
  
  <p>But I get an error "System.Management.Automation.RemoteException: Access to the path 'testDest' is denied.</p>
  
  <p>I'm an admin and WinRM is configured properly on both boxes. If I try to copy files remotely inside the same server (i.e. from \\serverA\c$\testSrc to \\serverA\c$\testDest) everything works fine.</p>
  
  <p>What's the proper way to do this?</p>