Resolving Issues Encountered While Spinning up SharePoint 2016 Management Shell

SharePoint Management Shell is the Swiss Army Knife in any SharePoint developer's/administrator's pocket. However when we run SharePoint Management Shell for the first time we might stumble upon a couple of issues if proper rights are not provided. In this article we will see some of the common permission issues related to setting up SharePoint Management Shell.

Let's try to spin up SharePoint 2016 Management Shell from the SharePoint Server.



I am running the management shell as a different user (Select “Run as different user”) who has been assigned permission recently.



This occurs because the login user name you had given is not assigned to the user policy “Allow log on locally”. This policy setting can be accessed through Start->Administrative Tools->Local Security Policy. Navigate to Local Policies->User Rights Assignment->Allow Log On Locally. In order to assign this policy setting to the user you can either add the user to any of the below groups or add the user directly.



Another alternative is you can run the 2016 Management Shell as Administrators shown below.



Click on Run as administrator. This would run the SharePoint 2016 Management Shell with Administrative group rights.



Thus we are able to log in to the SharePoint 2016 management shell. However we have got an error “The local farm is not accessible”. This is because the user does not have access to Config DB and does not have adequate Shell admin rights, and as a result we won’t be able to access SharePoint Object Model. We will have to provide the required permissions from SQL Server.

Spin up SQL Server Management Studio.



Go to Security tab and open up the properties window of the user.



Assign db_owner and SharePoint_Shell_Access rights to the below DBs,

  • SharePoint_Config – The configuration database of the farm
  • SharePoint_AdminContent – The Central Administration Database

Once you have given the access in SQL Server to the above databases, open SharePoint 2016 Management Shell in administrator mode again.



This time it opens up without any error messages. Let’s run some PS scripts to see it in action.



We have executed PS Scripts to list our Shell admin and web applications in the farm which has produced the above results.

Assigning the proper permission in SharePoint Server and SQL Server is the key to get SharePoint Management Shell running without any issues. Once it is done we can access SharePoint object model without any hassle.