Lock And Unlock The SharePoint Online Site

This blog will help you to Lock and Unlock the SharePoint Online sites.

Sometimes, a user may request you delete the SharePoint site which they were using or might not be using for a long time. At that time, as an administrator, we should not go for deleting the tenant site collection.

We should prefer to lock the site for quite some period. After some time, we can go for deleting the SharePoint online site. Then only, we can secure the user data for some time.

Here we go! The below is the PowerShell script to lock and unlock the site.

  1. //Connect the SharePoint online Admin center  
  2. Connect-SPOService -URL https://tenant-admin.sharepoint.com  
  3.   
  4. //Get the SiteCollection URL  
  5. $siteURL = “https://tenant.sharepoint.com/sitepages/home.aspx”  
  6.   
  7. //Lock the SharePoint Site  
  8. Set-SPOSite -Identity $siteURL -Lockstate “NoAccess”  
  9.   
  10. //Unlock the SharePoint Site  
  11. Set-SPOSite -Identity $siteURL -Lockstate “Unlock”  
Conclusion

As per the end-user view, the site has been deleted from SharePoint and they will get “403 FORBIDDEN” message in the browser. In case, the end-user has changed his/her decision to restore the Site, we can easily Unlock it.