ローカル 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
。