So, the story is the following:

I just joined a team of an existing sharepoint project, sharepoint is installed RTM on all environments, from DEV to production.

But because its 2 companies working for the same project, Me as a member of the 2nd company, my VM has .net framework 4.0 already installed.

So I was in charge of making some changes adding fields, features, etc.

And when I was going to use Enable-SP Feature I had this exception: I have 2 options so far:

  1. Install SP1, and the June CU in all environments. http://support.microsoft.com/kb/2536599

  2. Uninstall .net 4 from my environment.

  3. Here comes, the question, is there another way to solve it?

Update1: by checking the logs I found more info:

A PlatformNotSupportedException occured while trying to acquire the local farm: System.PlatformNotSupportedException: Microsoft SharePoint is not supported with version 4.0.30319.225 of the Microsoft .Net Runtime. at Microsoft.SharePoint.Administration.SPConfigurationDatabase.get_Farm() at Microsoft.SharePoint.Administration.SPFarm.FindLocal(SPFarm& farm, Boolean& isJoined)

  • 1
    I checked and all the projects inside the solution are .net 3.5 Commented Jul 11, 2012 at 13:15
  • i have the same error but not using powergui
    – user10590
    Commented Sep 7, 2012 at 12:50

3 Answers 3


Since this is a PowerGUI issue, you can fix it by following this solution. Follow these steps.

  1. Open your windows explorer and navigate to C:\Program Files (x86)\PowerGUI\ and open the configuration file ScriptEditor.exe.config.

  2. Change the supportedRuntime version under Startup settings by removing the version=”v4.0″ as below

Final <Startup> element

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

Now you can enjoy the powerful editor again.

If you check the startup settings and the version is v2.0.50727, try closing PowerGUI and reopening.

  • 1
    I don't use PowerGUI. I have this error in PowerShell command like this Restore-SPSite server_name/sites/site_name -Path C:\Backup\site_name.bak, what i must do? PS Sorry for my bed English, i'm a Russian :(
    – user13317
    Commented Nov 29, 2012 at 21:09
  • 2
    I was having this issue without PowerGUI as well but this solution gave me the hint to fix the issue. Simply launch powershell 2.0 instead of 4.0 from an administrative command prompt, like so powershell -version 2.0 (to add the sharepoint commands, run Add-PSSnapin Microsoft.SharePoint.PowerShell of course!). Commented Feb 13, 2015 at 3:13

If you dont use powerGUI but use powershell.exe:

  1. Go to:

  2. Find:

  3. Change:

    <?xml version="1.0" encoding="utf-8" ?> 
        <startup useLegacyV2RuntimeActivationPolicy="true"> 
            <supportedRuntime version="v4.0" />    


    <?xml version="1.0" encoding="utf-8" ?> 
        <startup useLegacyV2RuntimeActivationPolicy="true"> 
            <supportedRuntime version="v2.0" />    
  4. Save the file and it will work fine.

There is no need to change powershell.exe to

 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 '

That won't work if you want to run as admin, my simple solution above works just fine and should be the correct way!

It is similar to Fruqan's solutions.


I partially found the error.

POWERGUI tool is the guilty one, when I run the upgrade spsolution and install sp feature in the normal powershell window it works. In powerGUI it does not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.