2

PowerShellを使用してリモートマシンに接続できません。私が行った手順は次のとおりです。

  1. 有効化-PSRemoting-Force
  2. セットアイテムWSMan:\ localhost \ Client \ TrustedHosts *
  3. 再起動-サービスwinrm
  4. 入力-PSSessionIpAddress

サーバーマシンから最後のステップ(4番目のステップ)を実行すると、次のようなエラーが発生します。

Enter-PSSession:リモートサーバーへの接続が失敗し、次のエラーメッセージが表示されます:アクセスが拒否されました。

クライアントマシンとサーバーマシンの両方で、上記の4つの手順をすべて試しました。助けてください

ありがとうPrav

4

1 に答える 1

3

リモートマシンのポートを確認してください

PS Z:> cd WSMan:\localhost\Listener
PS WSMan:\localhost\Listener> dir
[cut]
PS WSMan:\localhost\Listener> cd .\Listener_1084132640
PS WSMan:\localhost\Listener\Listener_1084132640> dir
WSManConfig:
Microsoft. WSMan.Management\WSMan::localhost\Listener\Listener_1084132640
名前 値
---- -----
アドレス *
トランスポート HTTP
ポート 5985

次に、正しいポートに接続します

$remotePowerShellPort = 5985 $ConnectionURI = ("http://{0}:{1}" -f $targetServer, $remotePowerShellPort)
$remoteSession = New-PSSession -ConnectionURI $ConnectionURI
Invoke-Command -Session $remoteSession -ScriptBlock { dir削除-PSSession
$remoteSession

于 2011-03-31T09:37:45.833 に答える