![ローカルから PowerShell を使用してリモート サーバーに接続する方法。Enter-PSSession が機能しない (Exchange サービスとは関係ありません)](https://rvso.com/image/756729/%E3%83%AD%E3%83%BC%E3%82%AB%E3%83%AB%E3%81%8B%E3%82%89%20PowerShell%20%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6%E3%83%AA%E3%83%A2%E3%83%BC%E3%83%88%20%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E3%81%AB%E6%8E%A5%E7%B6%9A%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95%E3%80%82Enter-PSSession%20%E3%81%8C%E6%A9%9F%E8%83%BD%E3%81%97%E3%81%AA%E3%81%84%20(Exchange%20%E3%82%B5%E3%83%BC%E3%83%93%E3%82%B9%E3%81%A8%E3%81%AF%E9%96%A2%E4%BF%82%E3%81%82%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93).png)
ローカル PowerShell セッションを使用してリモート コンピューターに接続しようとしています。
そのために、ローカル PowerShell の Enter-PSSession または New-PSSession コマンドレットを次のように使用しようとしています。
$session = New-PSSession -ConnectionUri 'http://testserverUri.dom/PowerShell'
しかし、常に次の例外が発生します。
New-PSSession : [testserveruri.dom] Connecting to remote server apdv0710.forest7.dom failed with the following
error message : The WinRM client sent a request to an HTTP server and got a response saying the requested HTTP URL was
not available. This is usually returned by a HTTP server that does not support the WS-Management protocol. For more
information, see the about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = New-PSSession -ConnectionUri 'http://testserverUri.dom/ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotin
gTransportException
+ FullyQualifiedErrorId : URLNotAvailable,PSSessionOpenFailed
他のバリエーションも使用しました:
Enter-PSSession -Authentication Kerberos -ConnectionUri 'http://testserveruri.dom/PowerShell' -Cred $credential
Enter-PSSession : Connecting to remote server apdv0710.forest7.dom failed with the following error message : The WinRM
client sent a request to an HTTP server and got a response saying the requested HTTP URL was not available. This is
usually returned by a HTTP server that does not support the WS-Management protocol. For more information, see the
about_Remote_Troubleshooting Help topic.
At line:1 char:12
+ $session = Enter-PSSession -Authentication Kerberos -ConnectionUri 'h ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (http://testserveruri.dom/PowerShell:Uri) [Enter-PSSession], PSRemot
ingTransportException
+ FullyQualifiedErrorId : CreateRemoteRunspaceFailed
ほとんどの場合、最初の例外が発生します。
C# を使用して実行スペースを開き、リモート サーバーの powerSell URL で WSManConnectionInfo オブジェクトを提供しているときにも、同じ例外が発生します。
winrm コマンドに関してあらゆる方法を試しましたが、それでも問題は解決しません。どうすればこの問題を解決できますか?
答え1
なぜ単純にしないのですかEnter-PSSession apdv0710.forest7.dom
?
Enable-PSRemoting
まず apdv0710.forest7.dom で実行する必要があります。
答え2
これは、コンピューター名と、認証メカニズムとしての Kerberos、およびユーザー名とパスワードを含む資格情報オブジェクトのみを提供することで機能しました。
New-PSSession -Authentication Kerberos -Computer 'apdv004s' -Cred $credential
も同様の使い方ですEnter-PSSession
。