Thursday 11 February 2016

Not enough storage is available to process this command. (Exception from HRESULT 0x80070008)


When executing a PowerShell script using the invoke-command to remotely access several web servers, I encountered the following error message emanating from one of the servers.


The error message means the quota management of the remote shell is limited the amount of memory allocated to that shell. This allows the system to handle resource more efficiently. To resolve this issue it involves accessing the server locally and manually change the PowerShell MaxMemoryPerShellMB settings directly.

To resolve this error, login locally to the server, open a PowerShell session and run the following. 

sl WSMan:\localhost\Shell

Then check the size of memory allocated by running this

dir | Where-Object {$_.name -eq 'MaxMemoryPerShellMB' }

or the shorter version

get-item MaxMemoryPerShellMB

Below you can see the PowerShell memory setting was set to 100Mb.

I increased this with an extra 100mb set to total 200mb.

Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 200


So now when i run invoke-command remotely, the error did not occur and get the result I wanted.