Set SharePoint Web Application or Farm to Read Only Mode
During maintenance/migrations, it’s inevitable to set the entire SharePoint Farm or at least Web Applications to read-only mode for some time. SharePoint doesn’t provide any direct ways to set the entire web application or Farm to Read-only mode, but we have these options available to set read only access to either SharePoint Web Application or Farm.
- Using Central Administration user permissions
- Set read-only mode for all site collections of the web application through PowerShell.
- Set all SharePoint content databases of the web application to read-only mode.
Option 1: Using Central Administration User Permissions to Make SharePoint web application read only:
Go to Central Administration >> Application Management >> Manage web Applications >> and select “User Permissions”
Uncheck “Select All” and Select Permissions which start with “Open, View, Browse”. Such as: View Items, Open Items, Browse User Information.
This will make the selected web application read-only.
Option 2: Set read-only mode for all site collections of the web application through PowerShell To set SharePoint 2010 web application read only
Using SharePoint Central Administration, We can set the lock for a particular site collection, which is straightforward. Since, It’s possible to set the site collection to read-only mode using PowerShell, We can loop through each and every site collection in the web application and set the site collection’s status to read-only. Once done with the migration/maintenance, you can unlock the sites again.
Make SharePoint Web Application to Read only using PowerShell:
# Get the Web Application
$WebApp=Get-SPWebApplication "https://SharePoint.company.com"
#Loop through all site collections and Set read only status
foreach ($SPsite in $webApp.Sites)
{
$SPsite.ReadOnly = $true
#Or you can use: Set-SPSiteAdministration -LockState "Unlock" -Identity $SPsite.url
}
For More info on Site collection locks, refer to my post: Site Collection Locks in SharePoint
Option 3. Set all SharePoint content databases of the web application to read-only mode
Get the Content Databases Associated with the web application. Go to:
Central Administration >> Application Management >> Manage Content Databases >> Select the desired web application and make a note of all content databases.
Or you can use the PowerShell one-liner to retrieve all content databases of the web application:
You can repeat it for all web applications to make the entire SharePoint 2007 to SharePoint 2010 farm read-only.
Get-SPContentDatabase -WebApplication "https://SharePoint.company.com" | Select Name
Make the web app read only by setting all content databases to read only Mode
To set content databases to be read-only using SQL Server Management Studio:
- Open SQL Server Management Studio.
- Right-click the SharePoint content database and click Properties.
- Go to the Options tab, and in the Other options list, scroll to the State section.
- Set the Database Read-Only row to True, and then click OK.
- Repeat this for all content databases of the web application
You can do this for all web applications to make SharePoint farm read-only.
content db offline in CA does not mean that db goes to read-only mode. It just prevents creating new site collections.
Why not just set all the content database status to Offline in central admin? setting it to read only in sql will cause issue with updates.
Bad advice, setting content DBs to read only in SQL will break timer jobs.
Bad advice? Oops, then what Microsoft says about this, is bad!! Refer here:
https://technet.microsoft.com/library/ff607663%28office.14%29.aspx