Lock and Unlock SharePoint Sites in Microsoft 365 Using PowerShell

SharePoint Online, an integral part of Microsoft 365, serves as a valuable resource to collaborate and share information through dedicated sites. While SharePoint Online offers effective collaboration, there are instances where controlling site access becomes crucial, particularly to meet compliance requirements. In such situations, it is essential for an admin to know how to lock and unlock SharePoint sites. 

In this informative blog, we will explore the process of how to lock and unlock SharePoint sites in Microsoft 365. Let’s get started!


Purpose of Unlocking and Locking SharePoint Sites in Microsoft 365

Locking and unlocking the SharePoint sites serves the following essential purposes for the SharePoint site collection administrators:

  • Locking up the SharePoint sites helps the admins to prevent users from adding new contents when the site is under maintenance or upgradation. 
  • Keeping a SPO site in a read-only state ensures that the content remains unaltered and untouched by users. 
  • The unlock permissions allow the users to access or update the SPO sites that that have been locked or set to read-only.


Lock and Unlock Sites in SharePoint Online

In Microsoft 365, a Global administrator or a SharePoint administrator can restrict access to a SharePoint Online site collection using Windows PowerShell. 

Admins can perform any of the below listed SharePoint Online Sites operations with respect to their needs. Before getting started with any of the following listed operations, make sure to connect to the SharePoint Online PowerShell. You can use either Windows PowerShell or the SharePoint Online Management Shell to perform the cmdlet operations. 


Lock SharePoint Online Site Using PowerShell

As an admin, you can lock a particular SharePoint site in your tenant using the ‘Set-SPOSite’ cmdlet. 

The SharePoint ‘LockState’ parameter with the value ‘NoAccess’ in the above cmdlet renders the “Resource Portal” site inaccessible. Replace the site URL with the appropriate SPO site URL to lock access.  

When a user attempts to access the SharePoint Online site which has no access, they will receive a “403 FORBIDDEN” error. Lock a SharePoint Online Site


Set SharePoint Online Site to Read-only Mode Using PowerShell

The ‘ReadOnly’ value with the ‘LockState’ parameter in the ‘Set-SPOSite’ cmdlet makes the SharePoint Online site read-only mode. Users of the specific SharePoint Online site are unable to update any content within the site. 

The execution of the cmdlet with the appropriate SharePoint site URL makes the site read-only mode.

Read Only mode SharePoint Online Site

While accessing the SPO site having read-only permission, site owners and users will encounter a message stating, “This site is read-only at the administrator’s request.” 

Furthermore, when opening any documents on the site, these documents are also accessible in read-only mode. 

Note: To provide read-only access or different permission levels for only a certain set of SharePoint users, consider configuring SharePoint permission levels. 


Unlock SharePoint Site Collections Using PowerShell

To remove SharePoint site from read-only mode or no access mode, you can use the below cmdlet. 

Executing this cmdlet will bring the SharePoint Online site to its normal state without any restrictions. 

Note: This cmdlet will not unlock the site if the SharePoint site is closed and set to read-only through a site closure policy. 


Check Lock Status for Site Collections Using SharePoint Online PowerShell

Execution of the below cmdlet with the appropriate site URL gives the SharePoint lock state. 

Lock Status for Site Collections Using SharePoint Online PowerShell

To know which site collections are locked in SharePoint online, run the following cmdlet. 

Lock Status for all SharePoint and OneDrive Site Using PowerShell


Redirect SharePoint Sites with No Access to Another Site

Admins can opt to redirect the SharePoint site with restricted access to a particular URL rather than showing the usual “403 FORBIDDEN” page. To do so, utilize the ’Set-SPOTenant’ cmdlet with the required URL as demonstrated below. 

To revert the redirection, you can use an empty string (“”), indicating no redirection site URL. 

Note: If you want to manage site redirects to another page simply execute the same cmdlet with another site URL.


Important Points to Remember

  1. As of now, you can’t lock and unlock SharePoint sites through the Microsoft 365 admin center or SharePoint admin center. 
  2. The same configuration regarding the locking and unlocking SharePoint sites can be applied to the personal OneDrive sites. Configuring these operations in OneDrive sites will block the respective Microsoft 365 users from accessing or making changes to those sites. 
  3. SharePoint Online root site can’t be locked as it would potentially block access to critical administrative and organizational resources. 
  4. The SharePoint site collection can’t be deleted, if it is in a locked or read-only state.



In this guide, we’ve learned how to manage SPO sites, specifically focusing on how to lock and unlock SharePoint sites in Microsoft 365. These PowerShell cmdlets support your organization, helping you meet compliance requirements and maintain precise access control. 

If you have any questions about the blog, don’t hesitate to ask in the comments section. We’re here to address your inquiries.