Windows WinRM Error: Troubleshooting Guide
The error "The WS-Management service on the remote machine cannot process the shell request" typically occurs when you try to establish a remote PowerShell session (Enter-PSSession) or run a remote command (Invoke-Command) using Windows Remote Management (WinRM).
Description of the Error
This error means that the WinRM service on the target (remote) computer received your connection request, but it failed to create a command shell for you. The most common root causes include:
- MaxShellsPerUser limit reached: The remote machine has a strict limit on how many remote command shells a single user can open simultaneously. If previous sessions were not closed properly, the server blocks new ones.
- MaxMemoryPerShellMB limit exceeded: The processes running inside your remote session require more RAM than the configured limit allows on the remote machine.
- WinRM service corruption: The WinRM service or its listeners are misconfigured or hung up on the remote machine.
Step-by-Step Fixes
You must apply these fixes on the remote machine (the computer you are trying to connect to). Log into it directly or via Remote Desktop (RDP).
Fix 1: Increase the Maximum Shells Per User
This is the most common resolution. It raises the number of concurrent remote connections a single user can hold.
- Open the Start Menu on the remote computer.
- Type
powershell, right-click on Windows PowerShell, and select Run as administrator. - Check your current limit by running this command:
Get-Item WSMan:\localhost\Shell\MaxShellsPerUser - Increase the limit (for example, setting it to 50) by executing:
Set-Item WSMan:\localhost\Shell\MaxShellsPerUser 50 - Restart the WinRM service to apply changes:
Restart-Service WinRM
Fix 2: Increase the Memory Allocated Per Shell
If your scripts or commands consume a lot of resources, Windows might kill the shell request due to memory constraints.
- Open Windows PowerShell as an Administrator on the remote machine.
- Check the current memory limit (usually 1024MB by default):
Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB - Increase the memory limit to 2048MB (2GB) or higher by running:
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 2048 - Restart the WinRM service to apply the configuration:
Restart-Service WinRM
Fix 3: Kill Orphaned PowerShell Processes
If you cannot change the configuration limits right now, you can free up slots by terminating stuck background sessions.
- Open PowerShell as an Administrator on the remote machine.
- Look for background PowerShell processes running under your user account:
Get-Process wsmprovhost - Forcefully terminate all hidden remote host processes to clear up your shell quota:
Stop-Process -Name wsmprovhost -Force
Fix 4: Reconfigure and Reset WinRM
If the configuration changes do not resolve the issue, the WinRM listener state might be corrupted.
- Open Command Prompt (cmd) or PowerShell as an Administrator.
- Run the built-in configuration utility to repair listeners and firewall exceptions:
winrm quickconfig - If prompted to make changes or help enable the service, type
yand press Enter.
There may be some errors. Learn Microsoft