In this article, we can explore how to make a Site Collection read-only.
SharePoint 2010 - How to make a Site Collection Read-Only?In this article, we can explore how to make a Site Collection read-only.Why make a Site Collection Read-Only?During phases like development, requirements cut off and release the Administrator might require the Site-Collection to be read-only to prevent future add/edit/delete of contents.What are the ways to make Site Collection Read-Only?We can employ the following ways:
Depending on the requirements, we can use the above 3 ways. Let us explore all the 3 ways.Create Site CollectionFor demonstration purposes, I prefer you create a new site collection from Central Administration.In the page that appears, enter the site collection details.Open the site and ensure you can add contents.Option 1: Making Read-Only through Central AdministrationGo to Central Administration and select "Application Management" > "Configure quotas and locks".In the page that appears, choose the site collection and select the option Read-only.Enter the lock information and click the "Ok" button to continue.Testing Read-onlyNow we are ready to test the read-only functionality. Open the site collection main site and try to add a document. You should see the following error message.This ensures you cannot add/edit/delete contents. The site is read-only.UnlockingPlease return to the Central Administration Lock Page and choose "Not locked".Now the site collection will be back to writeable mode.Option 2: Making Read-Only through PowerShellNow let us try the PowerShell option. Open the SharePoint enabled PowerShell from the Start menu.Enter the following command for locking the SharePoint site collection by URL:Set-SPSite -Identity "http://hp/sites/sc2" -LockState "ReadOnly"Testing Read-onlyOpen the site collection main site and try to add a document. You should see the same error message.This confirms the site collection is now read-only.UnlockingNow to return the site to writeable, use the following code in a PowerShell window.Set-SPSite -Identity "http://hp/sites/sc2" -LockState "Unlock"Now the site collection will be restored to writeable mode.Option 3: Making Read-Only through CodeNow we can try the Server Object Model way of making a site collection read-only.Create a new console application, add a reference to the Microsoft.SharePoint assembly and execute the following code.
SPSite site = new SPSite("http://hp/sites/sc2");
site.ReadOnly = true;Testing Read-onlyOpen the site collection main site and try to add a document. You should see the following error message.This confirms that the site collection is now read-only.UnlockingNow to return the site back to writeable, use the following code.
site.ReadOnly = true;Now the site collection will have been restored to writeable mode.Please note that there are the following 3 lock options:
Referenceshttp://technet.microsoft.com/en-us/library/ff631148(v=office.14).aspx SummaryIn this article we have explored a real-world scenario of making the site collection read-only, through multiple options possible.
Basic Operations On SharePoint Using PnP PowerShell Scripts