28 January 2016

SharePoint 2013 - SpSite.rootweb returns blank URL

Recently I was running few SharePoint PowerShell scripts for a SharePoint development project. I was using an existing web-application and site-collection created in my SharePoint development environment.

I ran following command to get root-web of my web application -

$site=Get-Spsite 'https://<my web application>/'
$site.rootweb

I got following output -

Url
----


This meant that there is no root site collection associated with my web application. However this was not the case.

Then I ran following command -

$site.allwebs

I got following exception -

The following exception occurred while trying to enumerate the collection: "Cannot open database
"<My content DB name" requested by the login. The login failed.Login failed for user '<My Login ID>'.".

I gave access to my login id on content database and again ran the command -

$site.allwebs

This time I got following exception - 

The following exception occurred while trying to enumerate the collection: "There is a compatibility range mismatch between the Web server and database "<My content DB name>", and connections to the data have been blocked to due to this incompatibility. This can happen when a content database has not been upgraded to be within the compatibility range of the Web server, or if the database has been upgraded to a higher level than the web server. The Web server and the database must be upgraded to the same version and build level to return to compatibility range.".

Finally after lot of research on internet, I found the solution - I need to give my App Pool identity access on my content DB as well.

Once this is done, it started working fine.

To cut long story short, always given access on content DB to following Ids -

  • Your Login ID which is used for running code or PowerShell scripts
  • App Pool Identity

Hope this helps.

2 comments:

Michael said...

Thanks!
Just spend two hours on this...

Anonymous said...

What is minimum permission required on db?