At times we may require to set site collections to read-only to prevent any add/edit/delete operations on the site's content. During a SharePoint migration we decided to set sites to read only to restrict any updates. How to set site collection to read only in SharePoint 2013?
Set SharePoint 2013 site collection to read using Central Administration:
Usually making SharePoint 2013 site collections to read only is done at SharePoint Central administration site.
Once sites are in read-only, you may notice certain controls on ribbons, menus are disabled. But site content can be accessed as usual.
Set Site Collection Read Only with PowerShell
We can make SharePoint site read only using PowerShell. Open SharePoint Management Shell. Enter following command:
How to set all SharePoint sites to Read-only:
Unlocking SharePoint 2013 read only site collections
To revert the Read only mode, Return to the SharePoint Central Administration's Site collection Quotas and Locks page and choose "Not locked".
We can unlock the site collection using PowerShell by entering the command:
You can use STSADM also to set sharepoint 2013 site in read only mode
To make a SharePoint site read-only, Enter:
Stsadm -o SetSiteLock -url "Site-Collection-URL" -lock ReadOnly
To undo read-only, use:
Stsadm -o SetSiteLock -url "Site-Collection-URL" -lock none
Its also possible to make sites to read only using SharePoint Server Object Model: SPSite.ReadOnly = true. Setting up sites to read-only can be done at SQL Server also at content database level.
SharePoint site locks are explained in my another article: Site Collection Locks in SharePoint
Set SharePoint 2013 site collection to read using Central Administration:
Usually making SharePoint 2013 site collections to read only is done at SharePoint Central administration site.
- Go to Central Administration >> Select Application Management >> Configure quotas and locks
- Choose the site collection you want to set on Read-only mode and select the option “Read-Only". Choose farm administrator controlled or site collection administrator controlled options accordingly.
- Enter the lock information and click "Ok"
Once sites are in read-only, you may notice certain controls on ribbons, menus are disabled. But site content can be accessed as usual.
Set Site Collection Read Only with PowerShell
We can make SharePoint site read only using PowerShell. Open SharePoint Management Shell. Enter following command:
Set-SPSite -Identity "Site-Collection-URL" -LockState "ReadOnly"
How to set all SharePoint sites to Read-only:
Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
#Get all Site Collections
$SitesColl = Get-SPSite -limit All
#Loop through all site collections
ForEach($Site in $SitesColl)
{
Set-SPSite -Identity $site.Url -LockState "ReadOnly"
#You can also use: Set-SPSiteAdministration -LockState "ReadOnly" -Identity $Site.URL
}
Unlocking SharePoint 2013 read only site collections
To revert the Read only mode, Return to the SharePoint Central Administration's Site collection Quotas and Locks page and choose "Not locked".
We can unlock the site collection using PowerShell by entering the command:
Set-SPSite -Identity "Site-Collection-URL" -LockState "Unlock"
You can use STSADM also to set sharepoint 2013 site in read only mode
To make a SharePoint site read-only, Enter:
Stsadm -o SetSiteLock -url "Site-Collection-URL" -lock ReadOnly
To undo read-only, use:
Stsadm -o SetSiteLock -url "Site-Collection-URL" -lock none
Tips: If your site is read-only and you couldn't unlock it, your site may be in maintenance mode. Some times, SharePoint 2013 sites goes in read only mode after an interrupted backup. Try above methods to unlock. If they fail, You have to clear maintenance mode to revert read only: Maintenance Mode in SharePoint 2013
Its also possible to make sites to read only using SharePoint Server Object Model: SPSite.ReadOnly = true. Setting up sites to read-only can be done at SQL Server also at content database level.
SharePoint site locks are explained in my another article: Site Collection Locks in SharePoint