新しいファイルをリモートサーバーにコピーする前に、リモートサーバー上のフォルダをクリアする必要があります。
したがって、私のクライアントのスクリプトには次のものが含まれています。
Invoke-Command -Computer $TargetServer -ScriptBlock { Remove-Item $ClearPath }
これを実行すると、次のエラーが発生します。
Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests
私はこれをtechnetで調べました。これからの私の理解は、サーバーがプロキシを使用する場合(インターネットにアクセスしようとするときに使用する)、$PSSessionOptionオブジェクトを使用する必要があるということでした。そこで、以下が最初に実行されるようにスクリプトを変更しました。
$User = "group\tfs_service"
$Password = ConvertTo-SecureString -String "x" -AsPlainText -Force
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $Password
$PSSessionOption = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Negotiate -ProxyCredential $Credential
スクリプトを実行すると、次のエラーが発生します。
Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Setting proxy information is not valid when the HTTP transport is specified. Remove the proxy information or change the transport and try the request again
誰かが私がどこで間違っているのか教えてもらえますか?