In some scenarios it is required to put a site in read only-mode, for example a project site, or to simply just remove access to it.
From the SharePoint Online Admin Center there is no way to lock your site, or to put it in read-only. There are two ways to achieve this, one is through Powershell, the other one through the Site Settings of your Site Collection.
To remove the access to a site, use -LockState “NoAccess”. This will leave your site with a 403-error when you try to visit it afterwards.
To unlock a site, use -LockState “UnLock”.
$siteUrl = "https://YOURTENANT-admin.sharepoint.com" Connect-SPOService -Url $siteUrl $site = "https://YOURTENANT.sharepoint.com" Set-SPOSite -Identity $site -LockState "NoAccess"
Site Collection Site Settings
Another way of locking your site is through the site settings of your Site Collection. For me this is the better way, since it leaves your site accessible for your users (remember the Powershell option gives you a 403-error).
Navigate to the site settings and the Site Policies under “Site Collection Administration”.
Create a new Site Policy, give it a name and make sure to select the option “The site collection will be read only when it is closed.”.
Now you need to attach this policy to your site. Navigate to Site Closure and Deletion option under “Site Administration”.
As you might notice, the “Close this site now” button is disabled. You first need to assign a policy to the site before it is enabled.
We can now close the site.
If you want to open the site again, navigate back to the Site Closure and Deletion option and click on the “Open this site” button.
Original post: SharePoint Online lock/unlock your site