11 November 2014

SharePoint PowerShell error - The local farm is not accessible - Cmdlets with FeatureDependencyId are not registered

When you're new to a SharePoint farm, you may try to open the SharePoint Management Shell expecting to work in PowerShell.  Even though your account may be a local administrator on the server as well as a member of the SharePoint Farm Administrators group in Central Admin, you may still receive this error message:

The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered.




The issue is related to access to the configuration database for SharePoint.  What you need to do is grant access to the user in question, to the configuration database in SQL Server.  This can be done with the following two PowerShell commands:


$db = Get-SPDatabase | where {$_.Type -eq "Configuration Database"}
Add-SPShellAdmin "domain\username" -database $db

We begin by using the Get-SPDatabase cmdlet to get a reference to the SharePoint databases.  When you execute Get-SPDatabase by itself, it will provide you a listing of all SharePoint databases in the farm.  By filtering the type of database to only "Configuration Database" via the where clause, we are able to return on the configuration database in the farm.
Using the returned reference from this, we can use the Add-SPShellAdmin cmdlet to grant the user in question access to the configuration database.

Happy SharePointing!
C

image

No comments:

Post a Comment

Comments are moderated only for the purpose of keeping pesky spammers at bay.

SharePoint Remote Event Receivers are DEAD!!!

 Well, the time has finally come.  It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...