There are many different business scenarios when we want to set a SharePoint site collection as read-only mode (as shown in above screenshot) to prevent any further addition/modification of content but simultaneously to make the existing content available to the users. In SharePoint on-premise, this was primarily done via central administration or using powershell. But these tehniques do not apply to SharePoint Online.
Is there a way to make the site read-only via powershell?
Currently (July 2017) in SharePoint Online USING POWERSHELL THERE IS NO WAY TO SET THE SITE AS READ ONLY. Powershell only gives us below options where you can set a site to NO ACCESS. But this will make the whole site in accessible.
Set-SPOSite https://%5Btenant%5D.sharepoint.com/sites/targetsite -LockState NoAccess
The only two available options for LockState are NoAccess or Unlock, and there is NO READ ONLY options. See more about Set-SPOSite command here.
What is the easy technique which works?
You can use SharePoint OOTB site policies to set a site collection as read-only mode. When a site collection is closed using Site policy, there is an option to set it to read-only mode and the users will receive notification about the closure. Let’s see how to do it. You need to be an administrator to perform the below steps:
- Go to the Site collection and navigate to Site Settings page.
- Under Site Collection Administration, you can see “Site Policies“.Click on it and create a new policy with below settings.
Here we are defining a site policy which will not close the site or delete the site automatically but will set the site to read-only when it is closed by some other action.
3. Now let’s go back to Site Settings and under Site Administration, click on Site Closure & Deletion. Now select Site Policy as the one which we created in the above step and click on Close this site now.
(Sometimes you might see Close this site now is disabled even after selection of site policy. In those case select the policy, click OK and come back to page again).
Voila now you can see that the site is set to read ony and you can see the info bar on the top saying the site is now read only.