Table of Contents


Case

All of sudden my PowerShell stopped working with the following error

“The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered”

I am currently with SharePoint 2010 on my development machine on Windows 7 with SqP1. After having SharePoint installed for a couple of days PowerShell was working absolutely fine but now when I need to do something with scripting it has stopped working.

Steps

Tried two things very quick but still no luck:

  1. I have already tried to run PowerShell as an Administrator
  2. I have already given SharePoint_Shell_Access permission to the farm account on SharePoint Config. and Admin Content both databases.

As a next step I investigated the current version of PowerShell, I started PowerShell window and just ran the command:

$psversiontable

I found following:

As you can see it is PowerShell Version 3.0 which doesn’t support SharePoint 2010 http://blogs.msdn.com/b/ronalg/archive/2013/07/29/10382902.aspx?CommentPosted=true#commentmessage

Now how come it is upgraded to PowerShell 3.0?

I found that on my system there was a windows update installed as shown below. This upgrade has installed Windows Management Framework 3.0. WMF 3.0 also includes PowerShell 3.0, you can see on this link http://www.microsoft.com/en-us/download/details.aspx?id=34595

Solution

To resolve the issue quick: I changed PowerShell start menu short cut path and added –version 2.0 switch parameter, below is the complete path with –version 2.0 switch.

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' "

Add –version 2.0 switch;

By doing this I could run PowerShell 2.0 which support SharePoint 2010 commands

References

http://spshare.blogspot.in/2014/02/powershell-30-issue-with-sharepoint-2010.html