There are various situations where a site collection administrator has to make changes to the lock status of a/multiple site collections. It could be because you are migrating, or you want to execute some auditing and so on. Below is a script which can help you do the same. We can change the Lock state of a site collection to any of the available one. You can also add multiple site collections in the $sitelist parameter.
Hope it helps :) !
$sitelist = @("https://yoursitecollectionURL",)
foreach($site in $sitelist){
$s = get-spsite $site
$s.LockIssue = "Any text you want to add for logging purpose"
//Set-SPSite -Identity $site -LockState [NoAccess|UnLock|ReadOnly]
Set-SPSite -Identity $site -LockState NoAccess
}
Thanks for Script. Its great help.
ReplyDeleteJust update littlebit,
Get-SPSite http://mysitedev/* -LIMIT ALL | Set-SPSite -LockState NoAccess
this will reduce some effort to add site collection URL.
Appreciate your help. Yes, this saves a lot of effort, when you want to lock ALL site collections within that web app. I have had site migration on every weekend, where it helped us to lock what we wanted.
DeleteThank you.