Get SharePoint Site Collection Status in a Web Application
Below Code will help to get all the site collection status in a web application and save the consolidate output in an excel file.
$WebApp= Read-Host 'Enter Web Applcation URL to get site status'
$Sites = Get-SPWebApplication $WebApp | Get-SPSite -limit all | foreach {
if ($_.ReadOnly -eq $false -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $false)
{
$Result ="Not locked"
}
elseif ($_.ReadOnly -eq $true -and $_.ReadLocked -eq $false -and $_.WriteLocked -eq $true)
{
$Result = "Read-Only"
}
elseif ($_.WriteLocked -eq $true -and $_.ReadLocked -eq $false -and $_.ReadOnly -eq $false)
{
$Result = "Adding Content Prevented"
}
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 "File Location\Filename.xls" -Append
}
No comments:
Post a Comment