Hi @sns,
You can refer to following powershell script to get all sitecollections and subsites associated with database
If ((Get-PSSnapin | where {$_.Name -match "SharePoint.PowerShell"}) -eq $null)
{
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
Clear-Host
$webapps = Get-SPWebApplication
$Output = "C:\data.csv" #Output file
$SiteDataCollection = @() # Array to store data
foreach ($webapp in $webapps){
$webappurl = $webapp.URL;
$webappname=$webapp.DisplayName
$sites=get-spsite -limit all -WebApplication $webapp.URL
foreach ($site in $sites)
{
$ContentDB = Get-SPContentDatabase -site $site.url
$SiteData = New-Object PSObject
$SiteData | Add-Member -type NoteProperty -name "Web Application URL" -value $webappurl
$SiteData | Add-Member -type NoteProperty -name "Web Application Name" -value $webappname
$SiteData | Add-Member -type NoteProperty -name "Site Count" -value $($ContentDB.CurrentSiteCount)
$SiteData | Add-Member -type NoteProperty -name "Site URL" -value $site.url
$SiteData | Add-Member -type NoteProperty -name "Database Name" -value $ContentDB.Name
$SiteData | Add-Member -type NoteProperty -name "Database Size" -value $($ContentDB.DiskSizeRequired /1024/1024)
#$SiteData | Add-Member -type NoteProperty -name "Date Created" -value $site.RootWeb.Created
#$SiteData | Add-Member -type NoteProperty -name "OWner" -value $site.Owner
$SiteDataCollection += $SiteData
}
}
$SiteDataCollection | Export-Csv -Path $Output -Force
Write-Host "Successfully Completed" -ForegroundColor DarkRed
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.
test123