For some reason I got following error as I tried to run a PowerShell command:
“Microsoft SharePoint is not supported with version 4.0.30319.1008 of the Microsoft .Net Runtime.”
Luckily this one was already documented by Microsoft in following KB article: http://support.microsoft.com/kb/2796733
To work around this issue, change the Target field value for SharePoint 2010 Management Shell. To do this, follow these steps:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Version 2.0 -NoExit ” & ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\POWERSHELL\Registration\\sharepoint.ps1′”
Now the SharePoint Management Shell will open with the correct Version.
If you are using PowerGUI then you should check the config file of the script editor.
The normal location path is following: C:\Program Files (x86)\PowerGUI
Look for the appropriate config file: ScriptEditor.exe.config
If you see the entry with supportedRunTime version=”v4.0″, just delete this line or comment it out.
Now restart PowerGUI and try again to run your script/command.