Monday, February 17, 2014

PowerShell 3.0 issue with SharePoint 2010

All of sudden my PowerShell stopped working with 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 7with SP1. After SharePoint installation for couple days PowerShell was working absolutely fine but now when I need to do something with scripting it has stopped working.

Tried two things very quick but still no luck:-
  1. I have already tried to run PowerShell run as 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 run the command:-


I found following:-

As you can see it is PowerShell Version 3.0 which doesn’t support SharePoint 2010

Now how come it is upgraded to PowerShell 3.0, I found that on my system there was windows update installed as shown below, which has installed Windows Management Framework 3.0. WMF 3.0 also includes PowerShell 3.0, you can see on this link

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 swtich

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

Reference links:-