How can I run PowerShell with the .NET 4 runtime?

If you have powershell 4.0 then then PowerShell pickup .net framework 4.0 (by default ) as it built on .NET 4 runtime.
But for earlier powershell versions powershell 2.0, By default, PowerShell uses .NET version 2.0. But if you want to use classes implemented in later versions of the Framework You have to Explicitly tell powershell to use a later version of the CLR.

Example


    Add-Type -Path "C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.IO.dll
       

Copy and Try it


then you can load 4.0 dlls. You first need to load the relevant dll. You can do this as follows: To run PowerShell with the .NET 4 runtime, you have two options to make possible.
1. Changing registry setting.
Considering registry modification has its side-effects. I would choose second option being suitable for a particular purpose.
2. Changing powershell config file.
You have to be clear which 64-bit or 32-bit you are changing the value.
In 64-bit OS, the 32-bit powershell executable seems to pick up the change from there.