SharePoint – The local farm is not accessible

Below is an error one may receive when attempting to run SharePoint PowerShell cmdlets through the SharePoint Shell Admin:

“The local farm is not accessible. Cmdlets with FeatureDependencyID are not registered.”

OR

Get-SPContentDatabase : The farm is unavailable.
At line:1 char:1
+ Get-SPContentDatabase
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Microsoft.Share...ContentDatabase:
SPCmdletGetContentDatabase) [Get-SPContentDatabase], SPException
+ FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetConte
ntDatabase

This error can occur when the user running the commands doesn’t have the proper permissions to the correct back end content databases. The SecurityAdmin roles is necessary to run Shell commands. To resolve this error, either grant the account running the command sharepoint_shell_access and db_owner at minimum to the configuration database in SQL, or login with the SP_Admin account and run with elevated permissions.

If you already have the account granted the above permissions in SQL, you can run the following in a PowerShell console:

Add-SPShellAdmin -UserName DOMAIN\User