# Invoke-CimMethod ignoring MaxEnvelopeSizeKb

**URL:** <https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871>\
**Category:** PowerShell Help\
**Created:** [September 12, 2015, 7:58pm UTC](https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871 "2015-09-12T19:58:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry-buckle](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@henry-buckle](https://forums.powershell.org/u/henry-buckle)\
**Post date:** [September 12, 2015, 7:58pm UTC](https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871/1 "2015-09-12T19:58:34Z")

</div>

I am retrieving data from remote computers using WMI and the data can sometimes be larger than the default max envelope size.  
I have increased the default size using winrm set winrm/config @{MaxEnvelopeSizekb=“2048”} but when I call Invoke-CimMethod or Invoke-WSManAction I get an error “Invoke-CimMethod : The WS-Management service cannot process the request.The computed response packet size (533115) exceeds the maximum envelope size that is allowed (512000).”  
I have also tried using CimSessionOption to specify the size but it gives the same error.

```
$CitrixRsopProviderClass = Get-CimClass -Namespace root\rsop -ClassName CitrixRsopProviderClass
$options = New-CimSessionOption -MaxEnvelopeSizeKB 2048
$session = New-CimSession -ComputerName $Computer -SessionOption $options
$wmiC = Invoke-CimMethod -CimClass $CitrixRsopProviderClass -MethodName GetRsopRawData -Arguments @{'IsComputer'=$true;'username'=""} -CimSession $session
$wmiU = Invoke-CimMethod -CimClass $CitrixRsopProviderClass -MethodName GetRsopRawDataForSession -Arguments @{'sessionId'=1} -CimSession $session
```

However, using Invoke-WmiMethod does work, as does running the command using WMIC.

```
$wmiC = Invoke-WmiMethod -Class CitrixRsopProviderClass -Name GetRsopRawData -Namespace root\rsop -ComputerName $Computer -ArgumentList $true,""
$wmiU = Invoke-WmiMethod -Class CitrixRsopProviderClass -Name GetRsopRawDataForSession -Namespace root\rsop -ComputerName $Computer -ArgumentList 1
```

Is this a bug or is there some other reason that MaxEnvelopeSize is not being respected? I have tried using PowerShell 4 and 5, on Windows 7 x64.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [September 13, 2015, 11:51pm UTC](https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871/2 "2015-09-13T23:51:21Z")

</div>

If the default MaxEnvelopeSizeKB is 512000, why would you set it to 2048? If your response is 533115, you should set the MaxEnvelopeSizeKB to 600000 to return the record. If the passed value is less than the default MaxEnvelopeSizeKB, it is possible that it’s ignored as you would traditionally set it higher, not lower than the current default limit.

---

<div class="post-metadata">

**Author:** ![henry-buckle](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@henry-buckle](https://forums.powershell.org/u/henry-buckle)\
**Post date:** [September 14, 2015, 1:40am UTC](https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871/3 "2015-09-14T01:40:33Z")

</div>

I believe the numbers in the error message are in bytes, but when you set the MaxEnvelopeSize option it is in kilobytes - hence 2048KB or 2MB

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [September 14, 2015, 11:18pm UTC](https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871/4 "2015-09-14T23:18:40Z")

</div>

See if this works for you:

> **[CIM error - Michael Ryom](https://michaelryom.dk/cim-error/#.VfgS_hFVhBc)**
>
> I was trying get some hardware info via CIM, the other day and ran into this error message: Get-CimInstance : The response that the WS-Management service computed exceed the internal limit for envelope size. At line:4 char:12 + $Logical =...

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:44pm UTC](https://forums.powershell.org/t/invoke-cimmethod-ignoring-maxenvelopesizekb/4871/5 "2024-05-16T20:44:46Z")

</div>

Closed on May 16, 2024, 8:44pm UTC


