Updated 11 months ago

Lock and Unlock SharePoint Sites in Microsoft 365 Using PowerShell

by Thiraviam

5 min read

No Comments

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. Moreover, you can also create SPO alerts to track site content changes, while users have different permission levels within a site.

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 the site is in a locked or read-only state.
  5. The SharePoint site URL change can’t be performed if the site is in a locked or read-only state.

Optimize SharePoint Online Management using AdminDroid

As a Microsoft 365 admin, monitoring SharePoint Online statistics is crucial to ensure sites are free from suspicious activities. While the SharePoint admin center aids in monitoring SPO sites, it lacks certain insights such as site lock state, SPO site CA policy, and more. However, PowerShell offers these insights; challenges and errors within it can complicate the monitoring process.

But don’t worry! AdminDroid – Microsoft 365 reporting and auditing tool is here to help you. The SharePoint Online reports offered by this tool provide easy access to in-depth details on SPO site information, site members, document libraries, and more. With just a few clicks, it offers the following report collections on SharePoint Online:

  • SharePoint Online site collection reports
  • SPO site permissions reports
  • SharePoint Online usage reports
  • Reports on SPO lists & document libraries

All site collections report - AdminDroid

AdminDroid’s SharePoint Online auditing tool delivers finely detailed data on changes within your M365 SharePoint sites. It enables you to monitor SPO site usage, tracking every suspicious activity and permission change in SharePoint Online. The following are the SPO audit report collections offered by AdminDroid:

  • Site collection users & group audit reports
  • SPO sharing & access permission changes
  • SharePoint files & DLP audit reports
  • SPO site’s folder & page activities

Removed users or groups from site collections - AdminDroid reporting tool

Going beyond SharePoint Online management, AdminDroid offers 1800+ reports and 30+ dashboards covering all Microsoft 365 services with user-friendly AI graphics. AdminDroid also features effortless Microsoft alerting, compliance auditing, and delegation to reporting capabilities!

Download AdminDroid today and explore all the reports with the premium version during the 15-day free trial.

Conclusion:

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. Furthermore, we can also leverage PowerShell to efficiently manage file access in SharePoint Online, providing a comprehensive approach to site administration.

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

Share article