When running scripts in a large environment, you could run into an exception in PowerShell telling you it’s out of memory.
To get the value of the amount of memory available per shell, run the following command:
The PowerShell MaxMemoryPerShellMB quota defaults to only 150MB in v1 and v2, and 1024MB in v3.
But even under PowerShell 3.0 large objects can consume large amounts of memory.
You can resolve the ‘out of memory’ exception simply by increasing the value of MaxMemoryPerShellMB.
To accomplish this, use the following command:
As shown in the screenshot above, you can run the Get-Item command again to verify the command.
Last: Restart the winrm service… and you’re done 🙂