Saturday, September 20, 2014

Site collection stuck in read-only

This happened to me recently during an stsadm backup.  I was copying and pasting some code in a text file and I accidentally pressed ctrl+C in my stsadm window, killing the backup command.  Ooops! Since stsadm backups will set the site collection to read-only (unless you include the -nositelock flag), my site collection was stuck in read-only. This is a big problem in SharePoint 2013 since you cannot change this in Central Admin because the radio buttons to unlock a site collection are greyed out.  Oh no!

Beginning with the April 2013 CU you can run a simple powershell command to unlock a site collection. 
$Admin = new-object Microsoft.SharePoint.Administration.SPSiteAdministration('http://weburl/sites/sitecollectionurl’);
$Admin.ClearMaintenanceMode();

In my case I was on an RTM farm, so the ClearMaintenanceMode() command doesn't work.   Luckily there is still a way to fix it with a different powershell script.
$site = $get-spsite https://url;
$site.GetType().GetProperty("MaintenanceMode").GetSetMethod($true).Invoke($site, @($false));
Running this will unlock your site collection and you're back in business.

No comments:

Post a Comment