New-PSSession 问题 - 内容类型不存在或无效

问题描述 投票:0回答:1

我对 New-PSSession 命令有奇怪的问题。当我尝试使用

连接到服务器时

New-PSSession -ComputerName "xxx"

我有回应

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.

但其他用户可以连接到机器。有趣的是,登录此服务器时会发生相同的错误(我有错误,但其他人可以执行),所以看起来像是一些权限问题。我试过了

Set-PSSessionConfiguration -Name "PowerShell.7" -ShowSecurityDescriptorUI

我可以看到管理员可以执行所有操作,而我就是该计算机上的管理员。我还尝试了此网站的提示https://support.entuity.com/hc/en-us/articles/360019058197-How-do-I-configure-and-troubleshoot-WinRM但我仍然有同样的错误。有什么想法吗?

powershell winrm
1个回答
0
投票

这是我们几年前在远程服务器上遇到的问题。

您需要在每台需要远程 PowerShell 访问的服务器/计算机上执行的操作是从管理员 PowerShell 提示符运行

Enable-PSRemoting -Force
命令。

之后,您应该能够使用

New-PSSession -ComputerName <compName>
。确保您使用的是管理员控制台,或者使用 -credential 标志和正确的凭据来访问目标计算机。

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-5.1

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-5.1

© www.soinside.com 2019 - 2024. All rights reserved.