Strange Read-Only Behaviors of Site Collections
[SharePoint 2016, 16.0.5530.1000]
Suppose you have a site collection in read-only mode and want to remove that status. Normally this is achieved by selecting the "Not locked" option on the "Site Collection Quota and Locks" page in Central Admin or by running one of the following PowerShell commands:
(Get-SPSite "<https://siteCollectionUrl>").ReadOnly = $false
or
Set-SPSite "<https://siteCollectionUrl>" -LockState Unlock
There is also the LockState parameter of the Set-SPSiteAdministration command that can be utilized, but I did not try it in this particular case.
Nonetheless, there is a rare case where neither of these PowerShell commands works. They do not output any errors in PowerShell or even in verbose-enabled ULS logs when they fail to run, and the interface in Central Admin is grayed out as follows:
The site collection is truly locked for read-only access, as site collection admins do not see the full site menu. Additionally, a subsite within it displays a red banner at the top of page with the following message:
"We apologize for the inconvenience, but we've made OneDrive and sites read-only while we do some maintenance."
Remedy
It’s not entirely clear how the site collection entered this unusual state. It is most likely due to an unexpected failure of a backend operation. The good news is that the problem can be resolved by invoking the ClearMaintenanceMode() method of the SPSiteAdministration object, even though the MaintenanceWindows.Clear() method of the SPContentDatabase object doesn’t do the job at the database level. Before calling the method, however, let’s check the current value of the ReadOnly property of the object:
The ReadOnly property is True as expected, and it will indeed be set to False when the ClearMaintenanceMode() method is run:
$adm = New-Object Microsoft.SharePoint.Administration.SPSiteAdministration("<https://siteCollectionUrl>")
$adm.ClearMaintenanceMode()