Windows Error Fix: WinRM Shell Client Parameter Null or Zero
Description of the Error
This error occurs when you use the Windows Remote Management (WinRM) tool to execute commands on a remote system via Windows Remote Shell (winrs). The specific message The WinRM Shell client cannot process the request. One of the parameters required for the WinrsCloseShell function is null or zero indicates a protocol mismatch, unexpected connection termination, or session corruption.
It typically happens when the remote host terminates the command execution context unexpectedly, or when communication is blocked by a network device, firewall, or security software mid-session. It can also be caused by an outdated WinRM configuration, corrupted shell sessions on the target server, or strict group policies enforcing aggressive connection timeouts.
Step-by-Step Fixes
Follow these steps sequentially to resolve the issue. You may need administrative privileges on both the local machine and the remote target machine.
Step 1: Restart the WinRM Service on Both Machines
A corrupted memory state or hung session can cause this error. Restarting the Windows Remote Management service will clear existing sessions.
- Press the Windows Key + X and select Terminal (Admin) or Command Prompt (Admin).
- Type the following command to stop the service:
net stop winrm - Type the following command to start the service again:
net start winrm - Perform these steps on both your local computer and the remote server you are attempting to connect to.
Step 2: Increase WinRM Max Shells and Max Memory per Shell
The error can occur if your session hits the maximum allocated resource limits on the remote server, forcing the server to close the shell unexpectedly.
- Open PowerShell or Command Prompt as an Administrator on the remote machine.
- Run the following command to check the current configuration limits:
winrm get winrm/config/winrs - Increase the maximum memory allowed per shell to 2048 MB by executing:
winrm set winrm/config/winrs @{MaxMemoryPerShellMB="2048"} - Increase the maximum number of concurrent shells allowed per user to 30 by executing:
winrm set winrm/config/winrs @{MaxShellsPerUser="30"} - Restart the WinRM service on the remote machine using the instructions from Step 1 to apply changes.
Step 3: Verify and Re-register WinRM Service Components
Missing infrastructure configurations or listener corruptions can drop parameters mid-session. Re-applying the quick configuration command fixes structural problems.
- Open PowerShell as an Administrator on the remote server.
- Execute the self-healing setup command:
winrm quickconfig - If the service is already configured, it will analyze your environment. If it asks you to make changes or open firewall exceptions, type
yand press Enter.
Step 4: Adjust Network Timeouts and Keep-Alive Settings
If a firewall or a physical load-balancer drops idle connections, the WinRM client will attempt to close a shell that no longer exists on the server, causing a null parameter error.
- Open PowerShell as an Administrator on your local machine.
- Run this command to check your client timeout values:
winrm get winrm/config/client - Increase the operational timeout limit to 5 minutes (300,000 milliseconds) to prevent premature disconnection drops:
winrm set winrm/config/client @{Timeout="300000"}
Step 5: Check Windows Update and PowerShell Version Compatibility
A known protocol bug in older versions of the Windows Management Framework (WMF) can trigger this specific WinrsCloseShell error when communicating between different Windows Server versions.
- Check your PowerShell version on both machines by running:
\$PSVersionTable.PSVersion - If your remote machine is running Windows Server 2012 or Windows Server 2016 with an outdated version of WMF 5.1, navigate to Windows Update.
- Install all pending cumulative quality updates on both machines to patch the underlying WinRM engine binaries.
There may be some errors. Learn Microsoft