25

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

28

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

http://www.sharepointassist.com/2010/01/29/the-local-farm-is-not-accessible-cmdlets-with-featuredependencyid-are-not-registered/comment-page-1/#comment-1566

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"

18

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
7

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

  • Vote up for this. Also, the user may need to be in the local WSS_Admin_WPG group. – Underverse Oct 12 '15 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

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.

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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