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
You can override the .NET CLR version with these steps:
Create or edit a file at $pshome\powershell.exe.config
- If you use the ISE, also do the same for powershell_ise.exe.config
Insert or edit the contents so that the line for the v2.x supportedRuntime is listed before the v4.x line.
- Save the file and reopen any previous PowerShell sessions
- Test by adding the SharePoint snap-in, and running some SharePoint cmdlets, e.g.
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.