PowerShell Error: Cannot access the local farm

In new environments running the SharePoint PowerShell Scripts the following error can occur if the user does not have the permission to access the SharePoint Config DataBase


To Resolve the below error

Get-SPSite : Cannot access the local farm. Verify that the local farm is properly configured, currently available, and that you have
the appropriate permissions to access the database before trying again.
At *.ps1:28 char:9
+ $Site = Get-SPSite $SiteUrl
+         ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...SPCmdletGetSite:SPCmdletGetSite) [Get-SPSite], SPCmdletException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletGetSite

 Solution:

1) Open the SharePoint PowerShell as Administrator
2) Run the below code in the Shell

Get-SPDatabase | Add-SPShellAdmin SomeDomain\SomeUserName
 3) Log off and login again , This will resolve the issue.

Comments

Popular posts from this blog

How to copy SharePoint list workflow

Generate Auto number Field in SharePoint list

INFOPATH FORM HIDE/DISABLE FIELDS BASED ON SHAREPOINT GROUP MEMBERSHIP