【问题标题】:How to connect to remote server using powershell from local . Enter-PSSession not working如何从本地使用 powershell 连接到远程服务器。 Enter-PSSession 不工作
【发布时间】:2020-08-28 11:48:48
【问题描述】:

我正在尝试使用本地 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# 打开运行空间并为 WSManConnectionInfo 对象提供远程服务器 powerSell url 时,发生了同样的异常。

我已经对 winrm 命令进行了各种处理,但这并不能真正解决问题。 如何解决这个问题?

【问题讨论】:

  • Enter-PSSession 正在工作。您发布的错误抱怨 WinRM 的配置。 服务器是如何配置的?
  • Enter-PSSession 适用于本地主机。但是我想与远程服务器连接,并且在远程服务器上打开运行空间/会话时会出现所有这些问题。你可以看到我提供了远程服务器 url
  • 顺便说一句,这是 100% 的管理问题,应该发布在 serverfault.com
  • Enter-PSSession 也适用于远程会话。我正在使用它。您要求人们猜测远程服务器的配置方式。您是否尝试过使用谷歌搜索该错误消息?远程机器的操作系统版本是多少?
  • serverfault.com

标签: powershell powershell-remoting


【解决方案1】:

这对我有用,只提供计算机名称、Kerberos 作为身份验证机制以及包含用户名和密码的凭据对象。

New-PSSession -Authentication Kerberos -Computer 'apdv004s' -Cred $credential 

Enter-PSSession 的用法相同

【讨论】:

  • 新建-pssession,然后输入-pssession。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-04-16
  • 1970-01-01
相关资源
最近更新 更多