Saturday, November 19, 2011

Mount-SPContentDatabase failing on Blank Meeting Workspace

Today I have done a SharePoint content migration from SharePoint 2007 to SharePoint 2010 (database attach). But I got an error in PowerShell. In this post I would like to share the solution for this error with you.
Avoid running Mount-SPContentDatabase using the same database name in a single PowerShell window.

Backup your SharePoint 2007 Content Database
Open the SharePoint 2010 Management Shell
Run: Mount-SPContentDatabase
Hit enter, then fill in the name of the database and the web app you want to attach the database to
Upgrade completes successfully, the world is a happy place
Leave the PowerShell window open
You start messing with some customized sites and end up breaking one after doing the visual upgrade. You want to start over with a clean upgrade on the database.
Detach the content database from the SharePoint 2010 web application
Delete the database from SQL Server
Restore the backup
In the existing PowerShell window, run Mount-SPContentDatabase again
Upgrade fails.
You check out the upgrade file in the \14\Logs folder and there are some errors stating that upgrade did not occur on your site collections. At first, the only errors seemed related to the Basic Meeting Workspace site:
[powershell] [SPWebTemplateSequence] [ERROR]: Template MPS#0: SPWeb Id=f1c7b33e-ccf1-4c6c-b0ac-947d678a693a could not be accessed in SPSite Id=d587100d-220e-4732-8bff-ab765f377806 due to exception. Skipping this SPWeb for template upgrade. Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request)
at Microsoft.SharePoint.SPSite.GetSPRequest()
at Microsoft.SharePoint.SPSite.get_Request()
at Microsoft.SharePoint.SPSite.OpenWeb(Guid gWebId, Int32 mondoHint)
at Microsoft.SharePoint.Upgrade.SPWebTemplateSequence.ActivateWebFeatures(List`1 lstwebinfoToUpgrade, List`1& lstsiteidExceptions, List`1& lstwebinfoExceptions)
I did some further testing and created a site collection using each of the templates and reproduced again. This time I noticed all the site collections were failing to upgrade. All of them failing with a NullReferenceException. The Blank Meeting Workspace [MPS#0] was failing with the above stack, but the others were more subtle:
SPContentDatabase Name=wss_content
CanUpgrade [SPSite Url=http://UrlToWebsite/sites/] failed.
SPContentDatabase Name=SharePoint_Content_1
Exception: Object reference not set to an instance of an object.
Note: Removed the date/time and extra info from the log entry.

After a bit of troubleshooting, I found that as long as I open a new PowerShell window to run Mount-SPContentDatabase, the upgrade was consistently working.

No comments: