Getting site read and lcoked sites from group of site collections list

sns 8,656 Reputation points

I would like to retrieve read and locked site collections from bunch of site collections available in my CSV file from particular web application.
Could you please share script for this? Thank you

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,507 questions
{count} votes

Accepted answer
  1. Renjie Sun-MSFT 2,766 Reputation points Microsoft Employee

    Hi @sns ,

    You could refer this Powershell command template to export site collection URLs from CSV file:)

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
    Import-csv "C:\test\SitesList.csv" | ForEach-Object {  
    $Site = Get-SPSite $_.Url  
    if ($Site.ReadOnly -eq $false -and $Site.ReadLocked -eq $false -and $Site.WriteLocked -eq $false)  
        $Results = "Unlocked"  
    elseif ($Site.ReadOnly -eq $true -and $Site.ReadLocked -eq $false -and $Site.WriteLocked -eq $true)  
        $Results = "Read-Only"  
    #Adding Content Prevented?  
    elseif ($Site.WriteLocked -eq $true -and $Site.ReadLocked -eq $false -and $Site.ReadOnly -eq $false)  
        $Results = "Adding Content Prevented"  
    elseif ($Site.ReadOnly -eq $null -and $Site.ReadLocked -eq $null -and $Site.WriteLocked -eq $null)  
        $Results = "No Access"   
    New-Object -TypeName PSObject -Property @{  
                 SiteName = $Site.RootWeb.Title  
                 Url = $Site.Url  
                 SiteStatus = $Results}  
    }| Export-CSV $CSVFile -NoTypeInformation  

    Use this command you could export the results to a new CSV file. If you only want to display the results, the command of exporting to a new CSV file could be removed.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful