Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Lock and unlock sites

By using the permissions of a SharePoint Administrator or more in Microsoft 365, you can block access to a site or make a site read-only. Use Microsoft PowerShell to change the lock state of the site.

Note

You can't set the lock state on the root site. If the SharePoint administrator changes the SharePoint domain, OneDrive and SharePoint sites in a locked state (excluding sites connected to Microsoft Teams channels or Microsoft 365 Groups) are updated to the new domain.

Change the lock state for a site

Follow these steps to change the lock state for a site by using PowerShell.

  1. Install the SharePoint Online Management Shell by downloading and running the SharePoint Online Management Shell or installing the module from the PowerShell Gallery. If you installed a previous version of the SharePoint Online Management Shell, go to Add or remove programs and uninstall SharePoint Online Management Shell.

  2. Connect to SharePoint as a SharePoint Administrator in Microsoft 365. To learn how, see Getting started with SharePoint Online Management Shell.

  3. 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, traffic is redirected to the URL you specified. If you didn'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 doesn'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.


Feedback

Was this page helpful?

Additional resources