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
Last year I wrote a tweet about a new ‘secret’ PowerShell project I started working on.
I’m happy to anounce that v1 of the script is almost ready and …. I’ll be showing it for the first time on the Virtual PowerShell User Group on the 7th of March.
To give you an idea, this is the abstract of that session:
At each new customer there is a single thing I check before starting on a project: Active Directory health. You wouldn't believe the problems that you could encounter when AD isn't feeling that well, and what a headache it can cause when troubleshooting the issue(s). Over the last few months I've been working on a private PowerShell project: a health check for Active Directory environments. I'll show you the bumps in the road taken, the impact that scripting techniques can have on performance, the difference between choices (i.e. cmdlets vs. LDAP queries), and a first glimpse of the next step...
### SPOILER ALERT ! ! ! ###
Since I’ve been tweeting over the last few months about this I would, I will provide you with a small idea of what #possessod includes.
I’ve executed my script on an environment from one of my customers and the following was a part of the results:
Did I awaken you interest?