【问题标题】:HTTP error 307 while trying Powershell remoting尝试 Powershell 远程处理时出现 HTTP 错误 307
【发布时间】:2014-12-22 14:01:29
【问题描述】:

我的目标是通过 Powershell 从一个虚拟机运行命令到另一个虚拟机 - 没什么复杂的,对吧?

两台虚拟机在同一个子网,可以互相Ping。如果我打开 mstsc,我可以毫无问题地连接。到目前为止,一切顺利。

这是我的代码(在其他环境中工作,就像一个魅力):

$PSWD = ConvertTo-SecureString $Password -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($Username, $PSWD )
$Session = New-PSSession -ComputerName PC000003 -Credential $cred

这就是我得到的 -

New-Pssession : [PC00003] Connecting to remote server PC000003 failed 
with the following error message : The WinRM client received an HTTP 
status code of 307 from the remote WS-Management service. For more info...

我已经尝试过身份验证开关,没有任何变化。在两个虚拟机之间以及主机和虚拟机之间也尝试了相同的结果,结果相同。在名称和 IP 之间切换 - 结果相同。

用户名和密码正确且具有必要的权限(因为我可以通过 mstsc 成功连接)。 Google 返回很少提及状态码 307,其中大部分是关于 Exchange + Office 365 错误。

有什么想法吗,伙计们?

【问题讨论】:

    标签: powershell remote-access remote-desktop


    【解决方案1】:

    您是否尝试过使用 TEST-WSMAN。这个命令 let 应该知道是否在每个 VM 中启用了远程处理。如果是这种情况或者您不喜欢,您可以运行 Set-WSManQuickConfig。那应该启用远程处理。 Powershell 帮助中有几个帮助文件 about_Remote 和 about_Remote_TroubleShooting。

    【讨论】:

    • 您好,我之前在两台虚拟机上都启动过Enable-PSRemoting。我在两个虚拟机上都执行了Set-WSManQuickConfig,那里没有任何变化。另外 about_Remote_Troubleshooting 不包含与此 HTTP 307 错误相关的任何内容。
    【解决方案2】:

    我偶然发现了同样的错误。所有其他事情都被唤醒,ping,终端连接,网络共享等。但发现我们的防火墙阻止了 Powershell 连接。添加规则让 Powershell 连接通过并解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 2021-07-11
      • 2018-01-15
      • 2019-07-06
      • 2016-06-09
      • 1970-01-01
      相关资源
      最近更新 更多