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”.

403 The Website declined to Show this webpage - SharePoint Site Locks

How to Check Site Lock Status?

  1. You can navigate to: Central Administration > Application Management > Configure Quotas and Locks to get lock status.
  2. Get Lock status with STSADM
    stsadm -o getsitelock -URL
  3. Retrieve Site lock status with PowerShell:
    Get-SPSite “” | 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 "" | 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:
Set-SPSite -Identity https://sharepoint-sitecollection-url -LockState Unlock 

Fore more information on SharePoint site locks refer my post: Site Collection Locks in SharePoint

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

4 thoughts on “Check Lock Status for All Site Collections in SharePoint

  • For the read-only lock status, I just noticed that only following condition works where WriteLocked should also be $false

    #Read-only Lock?
    elseif ($_.ReadOnly -eq $true -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $false)
    $Result = “Read-Only”

  • Hi Salaudeen

    Thanks 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.


  • Hi

    I 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 “” -LockState Unlock
    then Get-SPSite “” | 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?



Leave a Reply

Your email address will not be published. Required fields are marked *