SharePoint 2010 PowerShell incompatibility with .NET 4.X


There is a known compatibility issue with SharePoint 2010 and Windows Management Framework 4.0 (WMF), which also includes PowerShell 3.0. If you install these components on a server that also runs SharePoint 2010, you may encounter errors when running SharePoint PowerShell cmdlets:

PS C:\> Add-PSSnapin Microsoft.SharePoint.PowerShell
The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

PS C:\> Get-SPEnterpriseSearchServiceApplication
Get-SPEnterpriseSearchServiceApplication : Microsoft SharePoint is not supported with version 4.0.30319.1008 of the Microsoft .Net Runtime.

Although this is not a supported configuration, there is a workaround to force PowerShell 2.0 documented in KB 2796733 - SharePoint 2010 Management Shell does not load with Windows PowerShell 3.0 

What isn't mentioned in the KB article is a different combination when this issue can occur, even if WMF 4.0 isn't installed. If your PowerShell version is 2.0 but configured to run with .NET 4.x CLR, you will still see the errors.

The $PSVersionTable will show the version of PowerShell and .NET that is being used.  If it shows a CLRVersion of 4.x, you will probably still have problems running SharePoint 2010 cmdlets:

PS C:\> $PSVersionTable

Name   Value
----   -----
PSVersion  2.0
CLRVersion  4.0.30319.1008

You can override the .NET CLR version with these steps:

  1. Create or edit a file at $pshome\powershell.exe.config
    1. If you use the ISE, also do the same for powershell_ise.exe.config
  2. Insert or edit the contents so that the line for the v2.x supportedRuntime is listed before the v4.x line.

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

  3. Save the file and reopen any previous PowerShell sessions

  4. Test by adding the SharePoint snap-in, and running some SharePoint cmdlets, e.g.

    A
    dd-PSSnapin Microsoft.SharePoint.PowerShell

This is similar to the procedure described in this post, but with forcing .NET version 2.x instead of version 4.x.

If this helps you, or if you still encounter these issues when running SharePoint 2010 PowerShell cmdlets, please post a comment or send me an e-mail.

Comments (10)

  1. mike says:

    This does not work on Win Server 2008 R2 after the changes are made for both PS and ISE, the program just force closes

  2. charles says:

    Same as Mike, both PS and ISE just force close.

  3. Neville says:

    Same as Mike & Charles. I notice our comments are all recent, so MS must have pushed new out a KB that is compounding the problem (seeing as Alex’s workaround was successful for all prior 2014). I see a lot of KB’s installed on my server 3/12/2014 & 4/9/2014.

  4. Mike Porter says:

    Seems like the file on Server 2008 is Powershell.exe.activation_config. It’s located at C:Program Files(x86)Common FilesNetApp.

    Hope this helps!

  5. Alex (blog author) says:

    I am pretty certain I tested this workaround without the SP2010 SP2 slipstream install. According to KB2724471, SharePoint 2010 should be compatible with Windows Server 2012 and 2012R2. They list the management shell errors under the resolved issues, but
    I haven’t tested yet. See:
    http://support.microsoft.com/kb/2724471/en-us

  6. MC HAmmer says:

    BIG-THX@Mike Porter
    Seems the NetApp Sharepoint Backup Software reconfigures the powershell… After adding the missing to C:Program Files(x86)Common FilesNetAppPowershell.exe.activation_config it is working.

  7. DHood82 says:

    I am having this problem on my existing server. Windows Server 2008 R2 with Sharepoint 2010. I do not have the directory listed in the above location (C:Program Files(x86)Common FilesNetApp) and I do not have a file of that name anywhere on my C: drive.
    The only config that i found was in C:WindowsSystem32WindowsPowerShellv1.0powershell_ise.exe.config. I added the extra line in the config but it didn’t work and it forced closed the ISE. This is the powershell version that I am using:

    Name Value
    —- —–
    PSVersion 4.0
    WSManStackVersion 3.0
    SerializationVersion 1.1.0.1
    CLRVersion 4.0.30319.18444
    BuildVersion 6.3.9600.16406
    PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
    PSRemotingProtocolVersion 2.2

  8. Henrik says:

    +1 for Mike Porter

    Seems like the file on Server 2008 is Powershell.exe.activation_config. It’s located at C:Program Files(x86)Common FilesNetApp.

  9. Mostness says:

    Huge thanks. Worked perfectly.

  10. Eric Bartels says:

    HAving the same problem as DHood82. Configuration the CLR with .config does not work. CLR 4 is always choosen. Even on Windows Server 2008 R2. Any help?

Skip to main content