Windows 错误: WinRM Shell 客户端无法处理请求
没有.
This error occurs when the Windows Remote Management (WinRM) service loses track of the unique identifier (shell handle) assigned to your remote session. It signifies a communication breakdown between your local machine and the remote server.
常见的原因
- Network Instability: 短暂的连接下降导致服务器丢失会话处理器.
- Session Timeouts: 远程服务器自动关闭置会话.
- Server Resource Limits: 远程机器击中了最大允许的同时弹.
- Service Crashes: 远程机器上的 WinRM 服务意外重新启动.
逐步修复问题
修复1:重新启动WinRM服务
在本地机器和远程机器上更新 WinRM 服务重新建立连接框架.
- 打开门 Start Menu.
- 它们的类型 cmd 或是 PowerShell.
- 右键单击应用程序并选择 Run as administrator.
- 它们的类型
net stop winrm然后按下. Enter. - 等到服务完全停止.
- 它们的类型
net start winrm然后按下. Enter.
修复2:增加每个用户的最大外
如果远程服务器因为资源耗尽而杀了您的处理器,则增加 shell 分配限制解决了问题.
- 打开 PowerShell 作为远程服务器的管理员.
- 通过运行检查当前限制:
Get-Item WSMan:\localhost\Shell\MaxShellsPerUser - 通过运行将限制提高到50:
Set-Item WSMan:\localhost\Shell\MaxShellsPerUser 50 - 使用从 命令重新启动 WinRM 服务 Fix 1 适用这些变化.
修复3: 调整空置时间截止属性
防止服务器在不活动期间过早关闭您的外手柄.
- 打开 PowerShell 作为远程服务器的管理员.
- 通过运行检查您当前的空时间设置:
Get-Item WSMan:\localhost\Shell\IdleTimeout - 将空置时间值设置为较高的值 (值为毫秒,7200000等于2小时):
Set-Item WSMan:\localhost\Shell\IdleTimeout 7200000 - 关闭并重新打开您的远程控制台.
修复4:重新连接和重置您的会话变量
如果您正在通过存储的会话变量运行脚本 (如 $Session 您必须清除并重建它.
- 在脚本或控制台中删除破损的会话变量:
Remove-PSSession $Session - 重新创建会话以获得一个全新的shell handle:
$Session = New-PSSession -ComputerName "RemoteServerName" - 输入新会话或再次运行命令:
Enter-PSSession $Session
可能有一些错误.. Learn Microsoft