如何修复 "WinRM客户端无法处理请求,因为指定的CustomRemoteShell URI不有效. "
没有.
This error occurs when the Windows Remote Management (WinRM) client attempts to establish a connection using a custom connection URI or shell plugin that is missing, misconfigured, or not registered on the target remote computer. WinRM relies on specific Uniform Resource Identifiers (URIs) to route commands to the correct shell environment (like PowerShell or CMD). If the client specifies a CustomRemoteShell 远程服务器不识别或不支持的URI,连接立即失败.
逐步修复问题
方法1:将 Shell 配置重新设置为默认设置
最快的解决方案是恢复本地机器和远程机器的默认 WinRM Shell 配置.
- 打开门 Start Menu.
- 它们的类型 cmd,右键按下 Command Prompt,并选择 Run as administrator.
- 键入下面的命令来重置 WinRM 配置,然后按下 Enter:
winrm quickconfig - 它们的类型 Y 然后按下. Enter 如果被要求做出改变.
- 接下来,通过运行:
winrm reset
方法2:在脚本中使用标准连接URI
如果您在运行PowerShell会话时收到此错误 ( New-PSSession 或是 Invoke-Command ),您可能明确传输错误的URI.
- 找到正在执行的脚本或命令.
- 检查一个
-ConnectionURI参数 - 确保您使用标准的PowerShell URI格式而不是自定义格式:
http://<RemoteComputerName>:5985/wsman - 另一个选择是移除
-ConnectionURI完全使用平坦的参数.-ComputerName相反的参数是:New-PSSession -ComputerName "TargetPC" -Credential (Get-Credential)
方法3:启用和配置远程访问
确保远程 shell 访问不受 Windows 组策略或本地配置的限制.
- 打开 Command Prompt as administrator.
- 运行此命令来检查是否启用远程:
winrm get winrm/config/winrs - 如果
AllowRemoteShellAccess如果设置为false,请通过运行启用:winrm set winrm/config/winrs @{AllowRemoteShellAccess="true"}
方法4:重新启动 WinRM 服务
有时 WinRM 服务无法正确注册其终端,直到服务被回收.
- 按下 Windows Key + R 打开运行对话框.
- 它们的类型 services.msc 然后按下. Enter.
- 滚向下来找到 Windows Remote Management (WS-Management) 服务.
- 右键点击它并选择 Restart.
可能有一些错误.. Learn Microsoft