locked
This user has exceeded the maximum number of concurrent shells RRS feed

  • Question

  • Hello All

    Error

    New-PSSession : [xxxxxxxxxxx] Connecting to remote server xxxxxxxxxxx failed with the following error message : The
    WS-Management service cannot process the request. This user has exceeded the maximum number of concurrent shells
    allowed for this plugin. Close at least one open shell or raise the plugin quota for this user. For more information,
    see the about_Remote_Troubleshooting Help topic.

    Remote Server

       WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Shell

    Type            Name                           SourceOfValue   Value
    ----            ----                           -------------   -----
    System.String   AllowRemoteShellAccess                         true
    System.String   IdleTimeout                                    7200000
    System.String   MaxConcurrentUsers                             10
    System.String   MaxShellRunTime                                2147483647
    System.String   MaxProcessesPerShell                           25
    System.String   MaxMemoryPerShellMB                            1024
    System.String   MaxShellsPerUser                               35

    PS WSMan:\localhost\Shell> Set-Item .\MaxShellsPerUser 50     < ====== Made no difference

    WARNING: The updated configuration might affect the operation of the plugins having a per plugin quota value greater
    than 50. Verify the configuration of all the registered plugins and change the per plugin quota values for the affected
     plugins.

    How do I "Verify the configuration of all the registered plugins and change the per plugin quota values for the affected plugins"

    e.g. what is my registered plugin called

    Reference https://docs.microsoft.com/en-gb/windows/desktop/WinRM/quotas

    Thank you

    Stephen Keogh

    Thursday, June 13, 2019 8:46 AM

Answers

  • Don't keep creating new sessions. Just create one session and reuse it.

    You can also use Invoke asjob without explicitly crating a session. The job manager will manage the remote sessions for you.

    Mostly your issue is a poorly thought-out design. Rethink and simplify.


    \_(ツ)_/

    • Marked as answer by StephenKeogh Tuesday, June 25, 2019 10:35 AM
    Thursday, June 13, 2019 11:33 AM

All replies

  • What plugin are you running?  We cannot guess at that.

    The settings also need to be set on the remote system and not the local system.


    \_(ツ)_/


    • Edited by jrv Thursday, June 13, 2019 9:03 AM
    Thursday, June 13, 2019 8:55 AM
  • Thank you for your prompt response ...

    >>What plugin are you running?  We cannot guess at that.<<

    Please advise how do I figure what plugin(s) I am using

    >>The settings also need to be set on the remote system and not the local system.<<

    As given in the question I have amended MaxShellsPerUser on the Remote Machine without success

    Thanks

    Stephen Keogh

    Thursday, June 13, 2019 9:55 AM
  • This happens often when running in a loop that repeatedly loads a module in certain ways.  You should first suspect your code.

    Also recursive calls can also cause code to exceed limits as recursion is a form of looping.


    \_(ツ)_/

    Thursday, June 13, 2019 10:07 AM
  • Thank you for your response ...

    >> This happens often when running in a loop that repeatedly loads a module in certain ways<<

    The following code extract is executed inside a ForEach-Object loop successfully 95 times over 5 hours. The final call 96 to the same code is outside of the loop and fails with "This user has exceeded the maximum number of concurrent shells"

    $BackupMachineName = my Remote Machine

    $Pso = New-PSSessionOption -IdleTimeout 1800000
        $Session = New-PSSession -ComputerName $BackupMachineName -Name Netbackup -SessionOption $Pso

        Invoke-Command -AsJob -Session $Session -ScriptBlock {
          param($CurrentNetbackupPolicy, $Policy, $Progress, $BackupDirectory)
          Remove-Item C:\tmp\netbackup_$CurrentNetbackupPolicy-*.txt
          Start-Process -FilePath "E:\Program Files\Veritas\Netbackup\bin\bpbackup.exe" -WindowStyle "Hidden" -RedirectStandardOutput C:\tmp\netbackup_standard_output.txt -RedirectStandardError C:\tmp\netbackup_standard_error.txt -ArgumentList "$Policy $Progress -w $BackupDirectory"

        } -ArgumentList $CurrentNetbackupPolicy, $Policy, $Progress, $BackupDirectory

        Exit-PSSession

    Thank you for your help

    Stephen Keogh 

     

    Thursday, June 13, 2019 11:15 AM
  • Don't keep creating new sessions. Just create one session and reuse it.

    You can also use Invoke asjob without explicitly crating a session. The job manager will manage the remote sessions for you.

    Mostly your issue is a poorly thought-out design. Rethink and simplify.


    \_(ツ)_/

    • Marked as answer by StephenKeogh Tuesday, June 25, 2019 10:35 AM
    Thursday, June 13, 2019 11:33 AM
  • Quick fix could also be to use Remove-PSSession to clean up old sessions. But if the script just loops forever, it's probably better to reuse the same session as Jrv pointed out.
    Friday, June 14, 2019 12:24 PM
  • Thank you for your prompt feedback ...

    I have amended my code to create a single session and reuse the same session. Amended code has been released to our Production environment and all is well

    I have marked your reply as my answer

    Thank you for your help

    Regards

    Steve

    Tuesday, June 25, 2019 10:39 AM