SharePoint 2010 - Cannot access the local farm.

Issue:

If you're encountering the following error, when trying to run a powershell script, you may not have sufficient permissions on the database.

Get-SPWeb : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have the appropriate permission to access the database before trying again.

The issue can be remedied with a few quick powershell commands.

Workaround:

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

Comments

Nathan Pillai said…
You may not have admin access on SharePoint database. Make sure you have enough permission to connect to DB. Powershell directly access the SharePoint Database.

Popular posts from this blog

C# - ListView Item Spacing (Padding)

C# / SQL - Performing Distributed Transactions

IIS / ASP.NET - Disabling Compatibility Mode/View (Internet Explorer)