28

Yes, I am logged into the machine as an administrator, and my domain account id a farm admin as well. The site is running properly, and nothing seems wrong in SP Central Administration. But when I start powershell, I get "Cannot access the local farm"

Also, running powershell with admin rights.

Where do I start to diagnose this issue?

Cheers, Daniel

1

7 Answers 7

29

Found it. My account needed proper rights in SQL Server, per this post:

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

It worked once I set "Sharepoint_Shell_Access" to the Sharepoint_Config database.

What got me here was searching for the first message: "the local farm is not accessible"

4
  • You should mark your own answer (with the check mark) Commented Jun 8, 2011 at 20:43
  • ah, would do so, but need to wait 2 days for some reason. odd Commented Jun 8, 2011 at 21:33
  • this is so people dont just boost their rep answering their own questions :-) Commented Jun 9, 2011 at 12:56
  • Also remember UAC can be an issue here. Check my blog post on that issue sites.wizdim.com/andersrask/sharepoint/… Commented Jun 9, 2011 at 12:57
17

Perform the following script in the SharePoint Management Shell, as a farm administrator and it will remove the error.

Get-SPDatabase | Add-SPShellAdmin SomeDomain\SomeUserName

This will grant the user both access to the configuration database as well as the content database.

Alternatively, you can revoke that granted access with the opposite command.

Get-SPDatabase | Remove-SPShellAdmin SomeDomain\SomeUserName
0
8

I know you are a farm admin, but try right clicking on Powershell, and select 'Run as Administrator'

1
  • Vote up for this. Also, the user may need to be in the local WSS_Admin_WPG group.
    – Underverse
    Commented Oct 12, 2015 at 23:50
4

It is possible that your PowerShell version is incompatible with the SharePoint Management Shell (commandlets).

Use below command to change the version used:

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;

3

In my case this was caused by my administrative user account not being in the list of users under the server. It used to be there, but it was mysteriously missing.

enter image description here

To make this more interesting, I added my user in manually to the server and it had all of the User Mapping already applied without my doing anything. It's almost as if some process kicked it off of the list but the databases kept the mapping.

enter image description here

2

Sometimes running as administrator does not work if the administrator does not have proper database / shell permissions, either. In that case, hold down shift and right-click on the PowerShell icon. Choose to run as a different user and run PowerShell as the farm account. Now you should be able to use Quinn Johns' answer to grant shell access to other accounts.

1

I had the same issue.

The local farm is not accessible

But after restart and repeating Add-PSSnapin Microsoft.SharePoint.Powershell it worked perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.