通过 powershell 使用 WinRM 时出现奇怪的行为,有时有效,有时无效

通过 powershell 使用 WinRM 时出现奇怪的行为,有时有效,有时无效

已经为我们所有的客户端机器设置了 Powershell Remoting(上周推出了 GPO),我几乎可以在所有机器上进行 Test-WSMan,并且得到了预期的良好响应。

现在,我们的其中一台服务器(我们的 SCCM 2012 包含所有最新更新)上,它时而工作,时而不工作,这让我抓狂。

[请注意,这是几天内通过 RDP 连续登录服务器的情况]

这是星期五下午

PS C:\Windows\System32\WindowsPowerShell\v1.0\Traces> Enter-PSSession -ComputerName D0373910

[D0373910]: PS C:\Users\A-RJS39534\Documents> Exit-PSSession

然后在周六早上从同一个 Powershell 窗口

PS BC1:\> Enter-PSSession -ComputerName D0373910
Enter-PSSession : Connecting to remote server D0373910 failed with the following error message : The WinRM client cannot process the request. It 
cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. For more information, 
see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName D0373910
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (D0373910:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

然后周日早上我回到

PS C:\Windows\System32\WindowsPowerShell\v1.0\Traces> Enter-PSSession -ComputerName D0373910

[D0373910]: PS C:\Users\A-RJS39534\Documents> Exit-PSSession

现在我又回到了这个问题

PS C:\Windows\System32\WindowsPowerShell\v1.0\Traces> Enter-PSSession -ComputerName D0373910
Enter-PSSession : Connecting to remote server D0373910 failed with the following error message : The WinRM client cannot process the request. It 
cannot determine the content type of the HTTP response from the destination computer. The content type is absent or invalid. For more information, 
see the about_Remote_Troubleshooting Help topic.
At line:1 char:1
+ Enter-PSSession -ComputerName D0373910
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (D0373910:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

真是让人抓狂!我已经为超大 Kerberos 票证设置了注册表设置,重新启动了服务,禁用并重新启用了 Powershell 远程处理。

当它想要工作时似乎只是碰碰运气。

有几件事要提一下

  • 服务器有 PS 4.0,大多数客户端有 2.0
  • 我所展示的系统在每次上述尝试之前都是可以 ping 通的
  • 这不适用于 Exchange Server(当我使用 WinRM 或 Powershell 远程处理搜索有关“内容类型缺失或无效”的任何内容时,似乎这是唯一出现的内容)

更新日期:2016 年 11 月 29 日

操作事件日志

Level       Date and Time           Source                  Event ID Task                       Category 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 33       WSMan Session deinitialize Closing WSMan Session completed successfuly   
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 8        WSMan Session deinitialize Closing WSMan Session 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 16       WSMan API call             Closing WSMan shell 
Error       11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 142      Response handling          WSMan operation CreateShell failed, error code 2150858999 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 254      None                       Activity Transfer 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 11       WSMan API call             Creating WSMan shell with the ResourceUri: http://schemas.microsoft.com/powershell/Microsoft.PowerShell and ShellId: 65AA33C1-1009-411E-8DEB-31E08D35AB17 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (16) - WSMAN_OPTION_TIMEOUTMS_SIGNAL_SHELL with value (60000) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (17) - WSMAN_OPTION_TIMEOUTMS_CLOSE_SHELL with value (60000) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (12) - WSMAN_OPTION_TIMEOUTMS_CREATE_SHELL with value (180000) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (1) - WSMAN_OPTION_DEFAULT_OPERATION_TIMEOUTMS with value (180000) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (25) - WSMAN_OPTION_LOCALE with value (en-US) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (26) - WSMAN_OPTION_UI_LANGUAGE with value (en-US) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 10       WSMan API call             Setting WSMan Session Option (34) - WSMAN_OPTION_USE_INTEARACTIVE_TOKEN with value (0) completed successfully. 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 31       WSMan Session initialize   WSMan Create Session operation completed successfuly 
Information 11/29/2016 10:19:13 AM  Microsoft-Windows-WinRM 6        WSMan Session initialize   Creating WSMan Session. The connection string is: D0375599-/wsman?PSVersion=4.0

第二次更新 2016 年 11 月 29 日

我刚刚才意识到,由于太匆忙,我从来没有清楚地说明过我想做什么。

我可以连接远程 Powershell 会话SCCM 服务器(2008 R2)。

我不能做的是连接到另一个系统SCCM 服务器(请注意,我尝试过的所有相关系统我都可以通过 Powershell 远程从我的 Windows 10 桌面连接到它们)

相关内容