All About PowerShell Versions

​As you guys know, SharePoint 2010 requires PowerShell 2.0 in order to leverage the Microsoft.SharePoint.PowerShell snap in. For most of us, working with recent versions of Windows Server such as Windows Server 2012 R2 with Update 1, PowerShell version 4.0 is the default version installed which causes conflicts with SharePoint 2010. Now if you wish to determine what version of PowerShell you have installed, you can use the following little trick. PowerShell includes a built-in variable named $PSVersionTable which contains information about the current version of the product that’s loaded in the shell. The following example was executed on my development server which has Windows Server 2012 R2 with Update 1 and the Windows Management Framework (WMF 5.0) February 2015 installed.

We can clearly see from that listing that my environment supports PowerShell Common Language Runtime (CLR) 1.0, 2.0,3.0, as well as 4.0 (based on the PSCompatibleVersions Property. This means that we should be able to tell our Powershell session to change the current CLR down to any of these versions. This can be achieved by calling the following line of PowerShell code:

PowerShell -Version xx

After executing the line above in your PowerShell session, the CLR will now be set to whatever version you asked for. It is important to note however that the CLR’s are based on the version .NET versions, and that they require the associated .NET version to be installed on your machine. For example, on my dev machine, I only have .NET 4.5 installed. If I try to set the PowerShell CLR to version 2.0, PowerShell will give me an error, letting me know I need to download and install the .NET 2.0 Framework. The error is shown below (Version v2.0.50727 of the .NET Framework is not installed and it is required to run version 2.0 of PowerShell).

In the case, simply go to the Microsoft Download Centre, download and install the bits to make this error go away and you’ll be able to downgrade the CLR to version 2.0 no problem.

Leave a Reply

Your email address will not be published. Required fields are marked *