SharePoint Asked by Elina on January 7, 2021
I want to make SharePoint on-premise and SharePoint online site collection to Readonly.
For SharePoint online i can able to achieve with Pnp commands.But on-premise is not working.
code i have used for SharePoint online :
Connect-PnPOnline -url $site -Credentials $credentials
Set-PnPSite -Identity $site -LockState ReadOnly
How we can set on-premise site to readonly.
I have tried like this , this also giving error.
$site = $clientContext.Site
$clientContext.Load($site )
$clientContext.ExecuteQuery()
$site.ReadOnly =$true # got an error ReadOnnly property is readonly.
You can use the following PowerShell command for SharePoint on-premises:
Set-SPSite -Identity "<SiteURL>" -LockState "ReadOnly"
References:Set-SPSite. / SharePoint 2013: Set Site Collection to Read Only.
UPDATE:
Here is another sample script which can be executed using Windows PowerShell:
Add-PSSnapin "Microsoft.sharepoint.powershell"
$Site = Get-SPSite -Identity “<SiteURL>”
$Site.ReadOnly = $true
I suppose the problem is how you get the site. The Site.ReadOnly property is still in function.
Answered by Chelsea_MSFT on January 7, 2021
This can be achieved using Site Policies:
Applying the policy and site closure can be done using CSOM if required.
Answered by Callum Crowley on January 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP