SharePoint 2010 Management Shell - .Net 4.0 runtime version error

SharePoint 2010 Management Shell - .Net 4.0 runtime version error

  • Comments 11
  • Likes

Written by Tamer Maher El-Sharkawy, Premier Field Engineer


Issue:

When you launch a SharePoint 2010 Management Shell you might receive one or both of the following errors:

  • “Microsoft SharePoint is not supported with version 4.0.30319 of the Microsoft .Net runtime”
  • “The local farm is not accessible. cmdlets with feature dependency are not registered.”

This could happen because the PowerShell version used by the shell isn’t the correct one.

Diagnostics:

At the command prompt run the following commands:

PS C:\ > $ver=$host | select version

PS C:\ > $ver.Version

Major  Minor  Build  Revision

-----  -----  -----  --------

3      0      -1     -1

If the version indicated is not “2”, the shell is indeed trying to execute with an unsupported runtime, and you get the error above.

Workaround:

First, try Import System Modules as shown:

clip_image002

If that does not resolve the issue, you can navigate to the Sharepoint Management Shell shortcut properties then add "-version 2" to the string in the Target field. Example:

C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe –version 2 -NoExit" & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "

clip_image004

Tamer Maher, MCP, MCTS, MCITP

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Very good content.

  • I am trying to find the "Import System Modules" is that something that I should download / have?

  • The example shortcut above does not work. The -Version 2 needs to be before -NoExit.

    Working shortcut is.

    C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe -Version 2 -NoExit " & ' C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1 ' "

  • Thank you Kent.  This syntax fixed my problem.  I am still not sure why it broke all the sudden.  I have been using sharePoint 2010 Management Shell several months without a problem.  All of the sudden it stopped working.  Wonder if it was due to updates.  Anyway,  all fixed.

  • Does NOT work for many processes that automatically use PowerShell like a scheduled task or PowerPivot with SSRS.

  • I am actually getting an error launching the SharePoint Management Shell  for SP2013 on a Windows Server 2012.

    select : The term 'Select-Object' is not recognized as the name of a cmdlet,

    function, script file, or operable program. Check the spelling of the name, or

    if a path was included, verify that the path is correct and try again.

    At C:\Program Files\Common Files\Microsoft Shared\Web Server

    Extensions\15\CONFIG\POWERSHELL\Registration\SharePoint.ps1:1 char:16

    + $ver = $host | select version

    +                ~~~~~~

       + CategoryInfo          : ObjectNotFound: (Select-Object:String) [], Comma

      ndNotFoundException

       + FullyQualifiedErrorId : CommandNotFoundException

    Any ideas?

    Thanks in advanced!

  • I tried this and the powershell starts then exits

  • thanks, man!!!

  • Thanks a lot

  • @Lou - did you find a solution for Select issue ?

  • Hi Leu,

    I fixed the 'select-object' problem in the following way. Hope it helps...

    I found $env:psmodulepath as C:\Users\user_name\Documents\WindowsPowerShell\Modules;;C:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules;C:\Program Files\AppFabric 1.1 for Windows Server\PowershellModules

    As you can notice that AppFabric module path has repeated itself. I guess AppFabric has messed up with the psmodulepath while it got installed. So, I modified the PSModulePath variable under registry (at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment) to include

    ;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

    After this change, I am able to execute select & other basic cmdlets.