none
This user has exceeded the maximum number of concurrent shells allowed for this plugin.

    Question

  • Hi,

    I have a powershell script that executes certain commands on a remote computer. Somewhere in the script the scenario is to execute a small powershell script that locates on the Remote computer only. For that I have created a new session so that the script will execute on the remote machine itself. Like this

    $newsession = New-PSSession -computerName $ServerIP -credential $Cred

    <Script execution>

    Exit-PSSession
    Remove-PSSession $svnsession

    Now when I run the complete script after sometime I started getting below issue

    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.

    I am not sure how these concurrent shells are getting opened and how I can avoid those.After writing 

    Exit-PSSession
    Remove-PSSession $svnsession

    I was expecting that the session was getting killed but with the error I am getting it does not looks like so. Please help me in this. Any suggestion to help me to get out of this situation is very welcome.

    Thanks in Advance

    Regards
    Girish

    Thursday, June 14, 2018 1:41 PM

All replies

  • You failed to show us how you are executing the script.


    \_(ツ)_/

    Thursday, June 14, 2018 2:06 PM
    Moderator
  • Hi I am sorry,

    But the main script is I run simply by executing Powershell script from powershell ISE and other powershell script  is like

    $newsession = New-PSSession -computerName $ServerIP -credential $Cred
        Enter-PSSession -Session $newsession
        invoke-command -file $ScriptPathRemote -Session $newsession-ArgumentList $SVNRepoPath, $RepoName, $SVNUser, $SVNPassword
        Exit-PSSession
        Remove-PSSession $newsession

    Above code I use to call other powershell script on remote machine.

    Regards,
    Girish

    Thursday, June 14, 2018 2:11 PM
  • You cannot do it like that.  You are just causing an endless loop of hung sessions.

    With Invoke command you don't need a session.  Enter-PsSession will not work.

    invoke-command -file <path to script on local computer> -computerName $ServerIP -credential $Cred

    That is all you need.


    \_(ツ)_/

    Thursday, June 14, 2018 2:14 PM
    Moderator
  • Initially I was doing that only and things are working perfect. But with one of the condition the script needs to be on the remote computer only. So the script is located on the remote computer and not on the local computer.

    Regards,
    Girish

    Thursday, June 14, 2018 4:36 PM
  • That is exactly what that command does.  It executes the script on the remote computer.  It doesn't "put" it there is "sends" it to the  remote computer and executes it on the remote computer all, in one command.


    \_(ツ)_/

    Thursday, June 14, 2018 5:45 PM
    Moderator
  • Okay this is an important input for me. Let me try this and will get back to you.

    Regards,
    Girish

    Thursday, June 14, 2018 7:44 PM
  • Hi,

    This works fine and resolves my issue. Thats great. Thanks a lot.
    One question out of curiosity, if in certain scenario we are getting the ps1 script located on the remote computer only and we want to execute the same at the remote end so how this can be achieved?

    Regards,
    Girish

    Monday, June 18, 2018 9:46 AM
  • Invoke-Command -ScriptBlock {& 'c:\temp\myscript.ps1'} -Computer <remotepc>


    \_(ツ)_/

    Monday, June 18, 2018 1:52 PM
    Moderator