Thursday, July 25, 2013

Resolving: The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.

If you try to run something like Get-SPWebApplication http://yourSpHere:1234 you may get the error:

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


Things to try.

1. Make sure you run the command as Administrator. For example, Go to Start Menu | All Programs | Microsoft SharePoint 2010 Products. Now right-click SharePoint 2010 Management Shell and choose Run as administrator.

2. If that doesn't work then it is likely you don't have access to the SharePoint configuration database. On solution would be to grant your users access to the configuration database, but that probably is not the best plan.

3. A better option is use a user that does have rights to the configuration database. This is often a SharePoint service account. If that service account has RDP access you one of your SharePoint front end servers then login as that service account and execute the command. If you want to be able to execute it with your specific account, then we need to do some more things. You can do the same thing as #1 to bring up the SharePoint 2010 Management Shell, and then execute

powershell prompt>Add-SPShellAdmin -UserName yourdomain\yourusername

This should make it so your specific user can now do #1.

If the SharePoint service account does NOT have RDP access then things are a bit trickier. In that case, follow these instructions:
  1. RDP to the SharePoint server using an account (usually in the adminstrators group in Windows) that can execute RunAs command.
  2. Go to Start Menu | All Programs | Accessories. Then righ-click on the Command Prompt item and select Run as administrator.
  3. Now we need to open the PowerShell prompt as the SharePoint service account. To do this, do the following command:

    cmd promopt>runas /user:yourdomain\yourusername C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  4. Type whoami at the prompt to verify that you are indeed the service account.
  5. At this point we have a standard Powershell prompt, but it doesn't know about SharePoint, so we need to add it. Use the following command to do so:

    powershell prompt>Add-PSSnapin Microsoft.SharePoint.Powershell
  6. Now you should be able to grant your specific user rights to use SharePoint powershell commandlets. To do so, use the following command:

    powershell prompt>Add-SPShellAdmin -UserName yourdomain\yourUserName
  7. Now you should be able to use method #1 with your specific user and not have to do all this fancy stuff everytime.

No comments: