Set SharePoint Online Site to Read Only using PowerShell

Requirement: Set SharePoint Online site to read only using PowerShell.

How to make SharePoint Online site read only? 
To make SharePoint online site collection to read only, use this PowerShell script in SharePoint Online Management Shell.
#Set Parameters
$AdminCenterURL="https://crescent-admin.sharepoint.com"
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"

#Connect to SharePoint Online
Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)

#PowerShell to set sharepoint online site to read only
Set-SPOSite -Identity $SiteURL -LockState ReadOnly
Once the execution of the above script is completed, you'll find a message appearing on top of the site: "SharePoint sites are read-only right now while we do some maintenance. We apologize for the inconvenience."
Set SharePoint Online Site to Read Only using PowerShell

To unlock the site collection, use:
#Unlock site from read only mode
Set-SPOSite -Identity $SiteURL -LockState Unlock
Here is my another post on making site read only using site policy: SharePoint Online: Make Site Collection Read only using Site Policies?
Set SharePoint Online Site to Read Only using PowerShell Set SharePoint Online Site to Read Only using PowerShell Reviewed by Salaudeen Rajack on February 15, 2019 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.