Check Lock Status for All Site Collections in SharePoint
End user came with a compliant: "I'm receiving 'HTTP 403: The Website declined to Show this webpage' in some sites", in an intranet collaboration environment. Ah! This is because: site is locked with "No Access".
How to Check Site Lock Status?
But for this case, End-user doesn't remember the URL. There are 5000+ site collections. How do I find which site collection has been locked with "No Access"? We have to retrieve lock status for all site collections. PowerShell comes to rescue again:
PowerShell Script to Get Lock status for all Site Collections:
How to Check Site Lock Status?
- You can Navigate to: Central Administration > Application Management > Configure Quotas and Locks to get lock status.
- Get Lock status with STSADM
stsadm -o getsitelock -URL http://sharepoint.crescent.com - Retrieve Site lock status with PowerShell:
Get-SPSite "http://sharepoint.crescent.com" | Select ReadOnly,Readlocked,WriteLocked
But for this case, End-user doesn't remember the URL. There are 5000+ site collections. How do I find which site collection has been locked with "No Access"? We have to retrieve lock status for all site collections. PowerShell comes to rescue again:
PowerShell Script to Get Lock status for all Site Collections:
Add-pssnapin Microsoft.SharePoint.Powershell -ErrorAction silentlycontinue #Get All Site Collections of a web app $Sites = Get-SPWebApplication "http://sharepoint.crescent.com" | Get-SPSite -limit all | foreach { #Check Lock Status #No Locks Applied? if ($_.ReadOnly -eq $false -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $false) { $Result ="Unlocked" } #Read-only Lock? elseif ($_.ReadOnly -eq $true -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $true) { $Result = "Read-Only" } #Adding Content Prevented? elseif ($_.WriteLocked -eq $true -and $_.ReadLocked -eq $false -and $_.ReadOnly -eq $false) { $Result = "Adding Content Prevented" } #No Access? elseif ($_.ReadOnly -eq $null -and $_.ReadLocked -eq $null -and $_.WriteLocked -eq $null) { $Result="No Access" } #Write the Result to CSV file separeted with Tab character $_.RootWeb.Title +"`t" + $_.URL + "`t" + $Result | Out-File LockStatus.txt -Append }
To unlock a site collection use:
Fore more information on SharePoint site locks refer my post: Site Collection Locks in SharePoint
Set-SPSite -Identity http://sharepoint-sitecollection-url -LockState Unlock
Hi
ReplyDeleteI terminated a PowerShell site backup early and now the site is in ReadOnly state and I could not change to unlock in CA.
So I tried to unlock the site with Set-SPSite -Identity "http://sitecollection.test.com" -LockState Unlock
then Get-SPSite "http://sitecollection.test.com" | select Readonly, Readlocked, WriteLocked
ReadOnly still show True ReadLock show False WriteLocked show False
I tried to change the site property $site.ReadOnly = False but the property didnot make the change ..
Could you please help. How do I set ReadOnly to False?
Swanl
Site could be in maintenance mode! Try this: Clear Maintenance Mode to Unlock a Site Collection in SharePoint
DeleteHi Salaudeen
ReplyDeleteThanks so much for your respond and solution. That's is what I need. I spent lot of time searching for answer and could not find anything related to the issue I had described. Until now. I really appreciate your helps.
Swanl
For the read-only lock status, I just noticed that only following condition works where WriteLocked should also be $false
ReplyDelete#Read-only Lock?
elseif ($_.ReadOnly -eq $true -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $false)
{
$Result = "Read-Only"
}