How to fix "The WinRM client sent a request to the remote WS-Management service and was notified that the request size exceeded the configured MaxEnvelopeSize quota."
The WinRM error message indicates that the data payload being transmitted between the client machine and the remote server exceeds the maximum size limit (MaxEnvelopeSize) allowed by the Windows Remote Management (WinRM) configuration. By default, WinRM sets a restriction on the packet size (often 512 KB) to prevent denial-of-service (DoS) attacks and excessive memory consumption. When you run a script, query large event logs, or pull heavy configuration data that surpasses this threshold, WinRM blocks the operation and throws this quota violation error.
To resolve this issue, you must increase the MaxEnvelopeSizekb value on both the source (client) machine and the destination (remote server) machine to ensure they can handle larger data packages.
Step-by-Step Fix
Follow these steps to increase the WinRM envelope size using Windows PowerShell. You must perform these steps on both the machine initiating the connection and the remote target machine.
Step 1: Open PowerShell as Administrator
- Click on the Start menu or press the Windows Key.
- Type PowerShell into the search bar.
- Right-click on Windows PowerShell from the search results.
- Select Run as administrator. Click Yes if a User Account Control (UAC) prompt appears.
Step 2: Check the Current MaxEnvelopeSize Value
Before making changes, check your existing configuration value by running the following command:
Get-WSManInstance -ResourceURI winrm/config | Select-Object MaxEnvelopeSizekb
Note down the default value (typically 512) so you have a baseline configuration.
Step 3: Increase the MaxEnvelopeSize Limit
Update the configuration to allow larger data sizes. Increasing this value to 8192 (which equals 8 MB) is generally sufficient for most heavy automation tasks and large data transfers. Run this command:
Set-WSManInstance -ResourceURI winrm/config -ValueSet @{MaxEnvelopeSizekb = "8192"}
Step 4: Verify the Changes
Ensure that the system successfully applied the new configuration setting by running the retrieval command again:
Get-WSManInstance -ResourceURI winrm/config | Select-Object MaxEnvelopeSizekb
Verify that the output now displays 8192.
Step 5: Restart the WinRM Service
To make sure all configurations take effect and active sessions clear, restart the Windows Remote Management service with this command:
Restart-Service -Name WinRM
Alternative Method: Group Policy Objects (GPO)
If you manage multiple machines in an Active Directory domain environment, you can deploy this fix globally:
- Open the Group Policy Management Console (
gpmc.msc). - Navigate to:
Computer Configuration->Administrative Templates->Windows Components->Windows Remote Management (WinRM)->WinRM Service. - Locate and double-click the policy named Specify maximum size of WS-Management packets.
- Set the policy status to Enabled.
- Input your desired value in kilobytes (for example,
8192) in the MaxEnvelopeSize field. - Click Apply and then OK.
- Run
gpupdate /forcein a command prompt on the target machines to apply the policy immediately.
There may be some errors. Learn Microsoft