Configure PowerShell to use DotNet 4.0

You might get following error when you load a snap-in that is written by DotNet 4.0.

This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

This is because by default, PowerShell uses DotNet version 2.0 CLR. To use powershell load DotNet 4.0 assemblies, the following settings need to be added in PowerShell.exe.config under C:WindowsSysWOW64WindowsPowerShellv1.0.

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319"/>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

Note:

  1. Above applies to 64bit windows server 2008 r2. On a 32 bit machine, PowerShell.exe.config can be found at C:windowsSystem32WindowsPowerShellv1.0
  2. Create PowerShell.exe.config if this file is not found.

Leave a Reply

Your email address will not be published.