Addressing the PowerShell Garbage Collection bug

There is a known bug where PowerShell does not correctly manage a garbage collection whilst executing a pipeline or loop of an object.

Simply using [System.GC]::Collect() within the pipeline or loop does not work as expected. Memory continually grows until the pipeline or loop has completed. This becomes a serious problem if you’re script is processing large objects. You can potentially exhaust memory resources and your script will fail with out of memory errors. This has been driving me nuts for years, as many of my Active Directory Health Check, Audit and Remediation Scripts process large objects in large environments.

There is a good overview of the bug here: No garbage collection while PowerShell pipeline is executing. Whilst this post claims that it seems to have been resolved in PowerShell 5, this doesn’t appear to be the case from my testing.

Read more

Windows 2003 SP2 64-bit Domain Joining Bug

On a recent project we were automating the build of 32-bit and 64-bit Windows 2003 SP2 servers. This was within a very large “Global” Active Directory environment, with many Trusted and External Domains. The 32-bit builds were working fine, but the 64-bit builds were not adhering to the Active Directory Sites and Services locations to … Read more