2

We have a deployment script that is failing with the error message: Not enough quota is available to process this command.

At the point where it fails it is attempting to start an executable asynchronously after having already started the same executable 10 times. So number 11 fails. A total of 17 need to be started. This script is not written in PowerShell but we use a remote PowerShell session to launch it and this error only happens when we run the script via PowerShell remoting.

If we run the same script directly on the server without using PowerShell remoting we don't get this error and the script has no problem launching all instances of the exe (17 in total) and finishing without error.

I have checked on the typical WSMAN limits that I suspected might be the cause of the error and they are set to unlimited as far as I can tell. At first I thought maybe MaxProcessesPerShell was set too low. Here are the results from the WSMAN drive on the server where this is running:

We have these WSMAN settings currently:

> WSMan:\localhost\Shell> dir

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

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

Is there any other PowerShell or WSMAN setting that might be the cause of this error?

The typical solution that is recommended for the Not enough quota... error involves making the Page file bigger. I have not tried that yet because the script runs error free outside of a PowerShell session.

I can provide more specifics about what our script is doing if that is needed to help answer this question.

Matthew MacFarland
  • 2,413
  • 3
  • 26
  • 34
  • This is not unique to PS, it happens for many reasons. I get that you only see it in the remote session. Are you releasing all your defined resources on each run? If not, you should, otherwise you could have a lot of stuff hanging around chewing up resources that they should not have. If you are running this multiple times, have you considered parallel process? Workflows/Runspaces – postanote Sep 05 '18 at 00:04
  • @postanote The resources are consumed by each instance of the exe that the script launches and then they are released when each exe instance exits as far as I know. We are using parallel processing. That is why we launch 17 instances of the exe and wait for them all to finish. I agree that the error does not seem specifically related to PowerShell but we have repeatedly tried this and the Not enough quota error ONLY happens when the script is launched in a remote PowerShell session. I can even run the script with a PowerShell prompt on the server and it works with no errors. – Matthew MacFarland Sep 05 '18 at 13:26

1 Answers1

2

The quota limit that was causing my error was the MaxProcessesPerShell setting on the PowerShell 32 bit plugin. This setting is independent of the Shell setting. To fix the issue I ran the follow commands in the remote PowerShell session...

 dir WSMan:\localhost\Plugin\microsoft.powershell32\Quotas\MaxProcessesPerShell

Results...

Type            Name                           SourceOfValue   Value
----            ----                           -------------   -----
System.String   MaxProcessesPerShell                           15

Change the setting to 25 with...

Set-Item WSMan:\localhost\Plugin\microsoft.powershell32\Quotas\MaxProcessesPerShell 25

Restart the WinRM service with...

Restart-Service WinRM

Tried running the problem script again with this new quota in effect and it now launches all 17 instances of the exe without any error. There is also a 64 bit PowerShell plugin which has it's own setting for this too.

This solution was found here Not enough quota is available to process this command

Matthew MacFarland
  • 2,413
  • 3
  • 26
  • 34