Execute all queued .NET Compilation Jobs

This PowerShell function will discover all installed .NET versions and process any Native Image Code queued jobs.

Basically, when you install or update .NET, it puts a bunch of compile jobs into the queue to be processed when the system is idle.
This is also the case if you install a .NET application, it too will place compile jobs into the queue.

If however you are making a golden image for deployment, or simply do not want to wait for the system to become idle enough to kick off the compile tasks, you can force the jobs to run immediately.

function Clear-NGENQueue {
	Write-Host Running NGEN compile for each applicable version. -ForegroundColor Green
	$NgenPath = Get-ChildItem -Path $Env:SystemRoot'\Microsoft.NET' -Recurse "ngen.exe" | % {$_.FullName}
	foreach ($element in $NgenPath) {
		Write-Host "Running .NET Optimization in $element";
		Start-Process -wait $element -ArgumentList "ExecuteQueuedItems"

Run the function by executing: