Monday, September 15, 2014

SharePoint 2013: Set Site Collection to Read Only

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.

  • 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"
Fortunately, Unlike its previous versions, SharePoint 2013 displays a banner "This site is read only at the farm administrator's request" to notify end users - when site collections are in read-only mode!
sharepoint 2013 set site collection read only
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



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

1 comment :

  1. Wow, I've used two of your scripts today! Thanks for posting. Adding your site to my SharePoint Favorites.

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...