Invoke-CimMethod ignoring MaxEnvelopeSizeKb

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Rob Simmers Rob Simmers 1 year, 6 months ago.

  • Author
    Posts
  • #29721
    Profile photo of Henry Buckle
    Henry Buckle
    Participant

    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.

  • #29733
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    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.

  • #29738
    Profile photo of Henry Buckle
    Henry Buckle
    Participant

    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

  • #29758
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    See if this works for you:

You must be logged in to reply to this topic.