Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
With permissions of a SharePoint Administrator or more in Microsoft 365, you can block access to a site or make a site read-only by using Microsoft PowerShell to change the lock state of the site.
Note
You can't set the lock state on the root site.
Change the lock state for a site
Follow these steps to change the lock state for a site by using PowerShell.
Download the latest SharePoint Online Management Shell.
Note
If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall "SharePoint Online Management Shell."
Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.
At the PowerShell command prompt, type the following command, and then press ENTER.
Set-SPOSite -Identity "<SiteURL>" -LockState "<State>"
Where:
SiteURL is the URL of the site that you want to lock or unlock and State is one of the following values:- Unlock to unlock the site and make it available to users.
- ReadOnly to prevent users from adding, updating, or deleting content. A message appears on the site stating that the site is under maintenance and is read-only.
- NoAccess to prevent users from accessing the site and its content. If you provided a NoAccessRedirectUrl value for your organization (below), traffic is redirected to the URL you specified. If you haven't set this URL, a 403 error is displayed.
Note
If the site was closed and made read-only through a site closure policy, the PowerShell command to unlock the site won't work.
Set-SPOTenant -NoAccessRedirectUrl 'https://www.contoso.com'
For more info about the LockState parameter, see Set-SPOSite. For more info about the NoAccessRedirectUrl parameter, see Set-SPOTenant.