Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
657 views
in SharePoint Server by 20 34 41
We have a web application that has about 100+ site collections and we need to lock them down.Is it possible to make the 100+ site collections read-only instead of manually?

1 Answer

1 like 0 dislike
by 20 34 41

To set several site collections to read-only mode use powershell

First, create a csv file that contains all sites URLs

Url
“Http://debug.com/sites/example1”
“Http://debug.com/sites/example2”
“Http://debug.com/sites/example3”

Second, open powershell and run the below script

Add-PSSnapin Microsoft.SharePoint.PowerShell
$Sites = import-csv “c:\temp\SiteCollections.csv”
Foreach($Site in $Sites)
{
Write-Host”Set Readonly:” $Site.Url
Set-SPSite -Identity $Site.Url -LockState “ReadOnly”
}
If you don’t ask, the answer is always NO!
...