PowerShell – Versions and More …

To analyze the PowerShell environment you need to dig into several framework components in order to know what you are dealing with.

First of all PowerShell is available in different flavors : 32 bit and 64 bit



It also has different releases Version 1 – 2 and 3 (at the moment)


More info you can get using these commands


The PS Version 3 adds different extra interesting modules like :

module(s) ‘ISE, CimCmdlets, PSScheduledJob, PSWorkflow, PSWorkflowUtility’

And last but not least PS accesses different versions of the .NET framework versions 1.x to 4.x

– Common Language Runtime (CLR) version

CLR 4.0.30319.296

Each version of the .NET Framework contains the common language runtime (CLR), the base class libraries, and other managed libraries.

Overview of the key features of the .NET Framework by version.

See information about the underlying CLR versions and associated development environments, and the versions that are installed by the Windows operating system.


For more info see here http://msdn.microsoft.com/en-us/library/bb822049.aspx

Configure PowerShell to use DotNet 4.0

So if you have an Assembly that is build on a certain .NET version, and you want to use the classes in PowerShell.

You better make sure it all falls together, otherwise it won’t work.

So basically, PowerShell (the engine) runs fine under .NET 4.0. PowerShell ( the console host and the ISE ) do not, simply because they were compiled against older versions of .NET

There’s a registry setting that will change the .NET framework loaded system wide, which will in turn allow PowerShell to use .NET 4.0 classes:

reg add hklm\software\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD /d 1
reg add hklm\software\wow6432node\microsoft\.netframework /v OnlyUseLatestCLR /t REG_DWORD

To update PowerShell, to use .NET framework without system wide impact, because it is too tricky.

Create this powershell.exe.config in the $pshome -> C:\Windows\System32\WindowsPowerShell\v1.0 folder.

<?xml version="1.0"?> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
        <supportedRuntime version="v4.0.30319"/> 
        <supportedRuntime version="v2.0.50727"/> 

IMPORTANT : For the x64 bit you need to copy it also to the 32bit folder -> C:\Windows\SysWOW64\WindowsPowerShell\v1.0

To update just the ISE to use .NET 4.0, you can change the config ($psHome \ powershell_ise.exe.config) file to have a chunk like this:

<?xml version="1.0"?> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
        <supportedRuntime version="v4.0.30319"/> 
        <supportedRuntime version="v2.0.50727"/> 

You can build .NET 4.0 applications that call PowerShell using the PowerShell API (System.Management.Automation.PowerShell) just fine.

How to determine which CLR version an Assembly or Executable is using, you can read here :

How To Determine Which CLR Version An Assembly Or Executable Is Using

I hope this made it not more confusing, as it already was before you started reading, because it is for me 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.