SP2010 “Cannot access local farm” issue
An error I’ve frequently encountered is the “Cannot access local farm” issue. This can come up when attempting to run a PowerShell script or STSADM command, and looks something like this:
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.
To work around this, run the following script in the SharePoint Management Shell, as a farm administrator.
Get-SPDatabase | Add-SPShellAdmin domain\username
This will grant the user access to both the configuration database and the content database.
To reverse the above command:
Get-SPDatabase | Remove-SPShellAdmin domain\username
Comments
When I am running the Get-SPWeb command from the Sharepoint application server. It is running fine.
However when I am connecting from my machine to the Sharepoint application server through PSSession and running the Get-SPWeb cmdlet, it is giving me the same error! I have banged my head a lot and tried a different combinations. But no luck! Is there any solution?