0

新しいファイルをリモートサーバーにコピーする前に、リモートサーバー上のフォルダをクリアする必要があります。

したがって、私のクライアントのスクリプトには次のものが含まれています。

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

誰かが私がどこで間違っているのか教えてもらえますか?

4

3 に答える 3

1

プロキシ(=中間者)による盗聴を回避するために、PowerShellクライアントとリモートPowerShellサーバー間の通信は安全である必要があります。そのため、PowerShellリモート処理はトランスポートがHTTPSの場合にのみプロキシをサポートします。

このブログ投稿ProxyServersand WinRMは、サーバー側のHTTPSリスナーをセットアップする方法と、プロキシを介してこのリスナーに接続する方法を示しています。

サーバー側のHTTPSリスナーを設定したら、次のようにクライアントからスクリプトブロックを呼び出してみてください。

Invoke-Command -Computer $TargetServer -ScriptBlock { Remove-Item $ClearPath } -sessionoption $PSSessionOption -UseSSL -Authentication Basic -Credential $Credential
于 2012-07-30T16:20:04.120 に答える
1

プロキシを設定する必要があると思って、間違ったツリーを吠えているようです。唯一の問題は、リモートサーバーでPowerShellリモート処理を有効にしていないことでした。昇格したPowerShellウィンドウで次のコマンドを実行することでこれを行うことができました。

Enable-PSRemoting
于 2012-07-30T15:44:44.040 に答える
0

他のサーバーでWinRmquickconfigを実行してみましたか?これにより、スクリプトの対象となるwinrmリスナーが構成されます

于 2012-07-31T12:02:08.243 に答える