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