In PowerShell you have a few options to increase the values of certain settings, in this example we will be looking at MaxMemoryPerShellMB setting that needs to be increased. The default value of 150mb might be fine in a small environment but in a larger environment where you are running long complex scripts, you may need to look at increasing the value.
To get the value of MaxMemoryPerShellMB, you can run the following command from an elevated PowerShell prompt:
- Get-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB
This will give you the output below:
In this example you can see it is set to 8192mb. To change this value, you can simply run the command below:
- Set-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB 8192
Once done you can restart the WinRM service with a simple command below:
- Restart-Service winrm
Once completed, test your scripts again and if you need to adjust the value again, you can do so.
Hope it helps.