Powershell を使用して、serverA から serverB にファイルをコピーしようとしています。どちらのサーバーもホスティング プロバイダーに属しているため、A から B へのファイルのコピーは、ローカル ボックスからいずれかのサーバーへのファイルのコピーに比べて非常に高速です。Powershell を使用して、serverA でリモート コマンドを実行し、ファイルを serverB にコピーできると考えました。これは私が思いついたものです:
$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
しかし、「System.Management.Automation.RemoteException: パス 'testDest' へのアクセスが拒否されました。
私は管理者で、両方のボックスで WinRM が適切に構成されています。同じサーバー内でファイルをリモートでコピーしようとすると (つまり、\\serverA\c$\testSrc から \\serverA\c$\testDest に)、すべて正常に動作します。
これを行う適切な方法は何ですか?