Get All Site Collections and SubSites Per Farm

Calculate Site Collection size per each content database using PowerShell

In this post, we’ll Get All Site Collections and SubSites Per Farm.

Get All Site Collections and SubSites Per Farm

Addiotnaly, we’ll explore the following:

Table of Contents
  1. 1 SharePoint Site Collections and Subsites
    1. 1.1 What’s the SharePoint Site Collection?
      1. 1.1.1 SharePoint Site Collection Limits and Recommendations
    2. 1.2 What’s the SharePoint SubSite?
      1. 1.2.1 SubSite Limits and Recommendations
  2. 2 Site Collections List Per Farm
    1. 2.1 Get All Site Collections Per Farm Using PowerShell
    2. 2.2 How many Site Collections Per Farm?
  3. 3 Site Collections List Per Web Application
    1. 3.1 Get All Site Collections List Per Web Application Using Central Administration
    2. 3.2 Get All Site Collections List Per Web Application Using PowerShell
      1. 3.2.1 Get Site Collection Administrator Using PowerShell
      2. 3.2.2 Get Site Collection Title Using PowerShell
    3. 3.3 How many Site Collections Per Web Application?
  4. 4 Site Collections List Per Content Database
    1. 4.1 Get All Site Collections Per Content Database Using PowerShell
    2. 4.2 How many Site Collection Per Content Database?
      1. 4.2.1 Current number of Site Collection Per Content Database Using Central Administration
      2. 4.2.2 Current number of Site Collection Per Content Database Using PowerShell
    3. 4.3 Which Content Database stores the Site Collection
  5. 5 Get Current Site Collection Size
    1. 5.1 Get Current Site Collection Size Per Web Application
    2. 5.2 Get Current Site Collection Size Per Content Database
  6. 6 Web Sites List Per Web Application
    1. 6.1 Get All Web Sites Per Web Application Using PowerShell
    2. 6.2 How many Subsites Per Web Application?
  7. 7 Web Sites List Per Site Collection
    1. 7.1 Get All Web Sites Per Site Collection Using PowerShell
    2. 7.2 How many Subsites Per Site Collection?
  8. 8 Web Application Vs Content Database Vs Site Collection Vs SubSites
  9. 9 PowerShell Script to get all Site Collections and Subsites details Per SharePoint farm
  10. 10 SharePoint Farm Scan Report

You may also like to check the full “SharePoint Farm Scan Report” PowerShell Script.


SharePoint Site Collections and Subsites

What’s the SharePoint Site Collection?

It’s the entire structure of the top-level site and all its subsites that have the same owner and share administrative settings.

SharePoint 2019 Site Collection Limitations

The top-level site is automatically created when you create a site collection. You can then create one or more subsites below the top-level site.

SharePoint Site Collection Limits and Recommendations

  • The maximum recommended number of site collections per farm is 750,000 site collections (500,000 Personal Sites plus 250,000 for all other site templates).
  • The supported limit for SharePoint Site Collections per Content Database is 10,000 site collections. (2500 for non-personal site collections and 7500 for personal site collections.)
  • Although the supported site collections are 10,000, it’s strongly recommended to limit the number of site collections per content database to 5000.
  • The recommended site collection size should not exceed 100 GB.
  • Larger site collections per content database lead to slowness and longer downtime during operation tasks like backup, restore and upgrade.

What’s the SharePoint SubSite?

It’s a web site (a group of related web pages) that you can create under the site collection.

Each new subsite can have its independent language and template.

Additionally, you can give permission to access your new site to the same users who have access to this parent site, or you can give permission to a unique set of users.

Max number of Sub-sites per site collection in SharePoint

Furthermore, you can also create additional subsites under a subsite.

Subsites Per site collection in SharePoint

SubSite Limits and Recommendations

  • The supported limit for subsites per farm is 250,000 subsites.
  • The supported limit for subsites per site collection is 250,000 and it’s the same number of subsites per farm.
  • The recommended subsites per site collection are 2000 subsites.
  • It’s recommended to deploy multiple site collections If you are planning to create more than 2000 web sites per site collection. In this case, the max site collections number that you can create per farm is 125 site collections. (125 site collection * 2000 web site) = 250,000 subsites and this the supported number of subsites per farm.

You may also like to check SharePoint 2019 Limitations.


Site Collections List Per Farm

As we earlier mentioned, the supported limit for SharePoint Site Collections per farm is 750,000 site collections.

The maximum recommended number of site collections per farm is 500,000 Personal Sites plus 250,000 for all other site templates.

Get All Site Collections Per Farm Using PowerShell

In Central Administration, you can get the full list of site collections per web application.

View all site collection in SharePoint

But it’s almost difficult to get the full list of site collections per farm!

In this case, you can easily use PowerShell to list all site collections per farm as the following:

  • Open SharePoint Management Shell as Administrator.
Open SharePoint 2016 PowerShell - Upgrade and Migrate to Project Server 2016
  • Run the below cmdlet.
Get-SPSite

Below is the result of running “Get-SPSite” to get the site collections list per farm.

Get Site Collections Per Farm in SharePoint

How many Site Collections Per Farm?

You can also get the count of Site Collections per farm using PowerShell as the following:

$SCCount = (Get-SPSite).count
Write-Host "the number of site collections per farm" $SCCount -ForegroundColor green
How many Site Collections Per Farm in SharePoint

Site Collections List Per Web Application

You can get the list of site collections per web application using PowerShell as well as the central administration.

Get All Site Collections List Per Web Application Using Central Administration

  • Open Central Administration, Click on “Application Management”.
  • Below “Site Collection”, click on “View All Site Collections”.
  • You can select which web application you would like to view its site collections as shown below.
View all site collection in SharePoint

Additionally, you can find

  • which content database the site collection is stored.
  • The Site Collection Title.
  • The Site Collection Administrator (Owner).

Get All Site Collections List Per Web Application Using PowerShell

Below are the steps to get the SharePoint Site Collections List per web application using PowerShell

  • Open SharePoint Management Shell as Administrator.
Open SharePoint 2016 PowerShell - Upgrade and Migrate to Project Server 2016
  • Run the below cmdlet
Get-SPSite -WebApplication "WebAppUrl"
Site collections list per web application using PowerShell in SharePoint

Get Site Collection Administrator Using PowerShell

You can get the Site Collection owner using PowerShell by specifying the owner field as shown below:

Get-SPSite -WebApplication https://epm:7000 | select url,owner,contentdatabase| Format-List
Get Site Collection Administrator for a site collection in SharePoint Using PowerShell

Get Site Collection Title Using PowerShell

You can get the Site Collection title using PowerShell by using @{Name=”Site Collection Title”; Expression={$_.RootWeb.Title}}

Get-SPSite -WebApplication https://epm:7000 | select url,@{Name="Title"; Expression={$_.RootWeb.Title}},owner,contentdatabase| Format-List
Get Site Collection Name in SharePoint Using PowerShell

How many Site Collections Per Web Application?

To know How many site collections per web application using PowerShell, you should do the following:

  • Open SharePoint Management Shell as Administrator.
Open SharePoint 2016 PowerShell - Upgrade and Migrate to Project Server 2016
  • Run the below cmdlet
$SCCount = (Get-SPSite -WebApplication http://epm:7000).count
Write-Host "the number of site collections per web application" $SCCount -ForegroundColor green
How many Site Collections Per web application in SharePoint

Site Collections List Per Content Database

As we earlier mentioned, the supported limit for SharePoint Site Collections per Content Database is 10,000 site collections. (2500 for non-personal site collections and 7500 for personal site collections.)

Although the supported site collections are 10,000, it’s strongly recommended to limit the number of site collections per content database to 5000.

Get All Site Collections Per Content Database Using PowerShell

In Central Administration, there is no option to get the list of site collections per content database.

In this case, you should use PowerShell to get the site collections list per content database by running the below cmdlet:

Get-SPSite -ContentDatabase "Content Database Name"
Get Site Collection list per content database in SharePoint

How many Site Collection Per Content Database?

You can get the count of Site Collection per Content Database using the Central Administration as well as the PowerShell.

Current number of Site Collection Per Content Database Using Central Administration

To get how many site collections per content database using central administration, you should do the following:

  • Open Central Administration, below Application Management, click on “Manage content databases”.
Get All Site Collections and SubSites Per Farm
  • You can get the list of content databases and the number of associated site collections per a specific web application.
Content database per content database in sharepoint

To show the list of a content database for a specific web application, you should click on “Change Web Application” and select the web application that you need to list its associated content databases.

Current number of Site Collection Per Content Database Using PowerShell

To know How many site collections per content database using PowerShell, you should run the below cmdlet:

$SCCount = (Get-SPSite -ContentDatabase PWA_Content_DB_7000).count
Write-Host "the number of site collection per content database" $SCCount -ForegroundColor Green
How many site collections per content database using PowerShell

Which Content Database stores the Site Collection

As we earlier discussed, you can know the associated content database for a site collection using Central Administration.

View all site collection in SharePoint

Here, we’ll learn how to know which content database the site collection is stored using powerShell.

Get-SPSite -WebApplication https://epm:7000 | select contentdatabase,url| Format-List
which content database the site collection is stored using powerShell

Get Current Site Collection Size

In this section, we will show how to use PowerShell to

  • Get Current Site Collection Size Per Web Application.
  • Get Current Site Collection Size Per Content Database.

Get Current Site Collection Size Per Web Application

Using PowerShell, you can get the current size of each site collection per web application by running the below cmdlet:

Get-SPWebApplication -Identity http://epm:7000 | Get-SPSite | select url,@{Name="Site Collection Size (MB)";Expression={[math]::Round($_.usage.storage/(1MB),2)}}
get the current size of each site collection per web application in SharePoint

Get Current Site Collection Size Per Content Database

Using PowerShell, you can get the current size of each site collection per content database by running the below cmdlet:

Get-SPSite -ContentDatabase "Content Database Name" | select url,@{Name="Site Collection Size (MB)";Expression={[math]::Round($_.usage.storage/(1MB),2)}}
Get Current Site Collection size Per Content Database in SharePoint

Web Sites List Per Web Application

As we earlier mentioned, The supported limit for subsites per farm is 250,000 subsites, and it’s the same supported number per site collection.

Get All Web Sites Per Web Application Using PowerShell

Actually, It’s almost impossible to list all subsites (web sites) per a web application.

In this case, you should use Powershell to get the subsites list per web application.

Get-SPWebApplication http://epm:19812 | Get-SPsite | get-spweb -Limit all
Get web sites Per Web Application Using PowerShell in SharePoint

Note: This result includes the parent site and its subsites.

How many Subsites Per Web Application?

To know How many subsites per web application, you should run the below cmdlet:

$subsiteCount=(Get-SPWebApplication "Web APp URL" | Get-SPsite | get-spweb -Limit all).count
Write-Host "The number of Subsites per web application is" $subsiteCount -ForegroundColor green
How many sub-sites per web application in SharePoint

Web Sites List Per Site Collection

As we earlier mentioned, the number of recommended subsites per site collection is 2000 subsites.

If you are planning to create more than 2000 web sites per site collection. It’s recommended to deploy multiple site collections. In this case, the max site collections number that you can create per farm is 125 site collections. (125 site collection * 2000 web site) = 250,000 subsites and this the supported number of subsites per farm.

Get All Web Sites Per Site Collection Using PowerShell

In Site Content, you can only get the list of subsites for the current parent site.

Subsites Per site collection in SharePoint

But, if you would like to get the full list of all subsites under the current site collection, you should run the following cmdlet:

Get-SPsite -Identity "Site Collection URL" | get-spweb -Limit all
how many sub sites per site collection in SharePoint

How many Subsites Per Site Collection?

To get the count of all subsites per site collection, you should run the below cmdlet:

$SubSiteCount = (Get-SPsite -Identity "Site Collection URL" | get-spweb -Limit all).count
Write-Host "the number of subsites per site collection is" $SubSiteCount -ForegroundColor green
Get sub sites count per site collection in SharePoint

Web Application Vs Content Database Vs Site Collection Vs SubSites

  • Each web application can hold multiple Content Databases.
  • Each web application can hold multiple Site Collections.
  • Each Content Database can hold multiple Site Collections.
  • Site Collection can be only stored in one Content Database.
  • You can’t create a site collection without having a web application with a content database.
  • Each Site Collection can hold multiple SubSites.
  • Each SubSite can also hold additional SubSites.
  • You can’t create a subsite without having a top-level site collection.

You may also like to read


PowerShell Script to get all Site Collections and Subsites details Per SharePoint farm

In this section, we’ll introduce a simple PowerShell script that helps you to get the following:

  • The list of all SharePoint Site Collections per farm.
  • The list of all SharePoint Site Collections per web application.
  • The list of all SharePoint Site Collections per content database.
  • The list of all SharePoint Subsites per site collection.
  • Which Content Database stores the Site Collection?
  • What’s the current size of Site Collection?
  • How many site collections per farm?
  • How many site collections per each web application?
  • How many site collections per each content database?
  • How many Subsite per each site collection?
  • A warning alert if the supported limit exceeded.
Get All Site Collections and SubSites Per Farm

Download the “Site Collections and SubSites per SharePoint farm” script on GitHub.


SharePoint Farm Scan Report

SharePoint Farm Scan Report is a PowerShell Script that helps you to scan farm objects to monitor the SharePoint farm limits by getting real statistics that would help you to administrate your farm effectively and efficiently.

SharePoint Farm Scan Report Statistics includes:

  1. List of SharePoint web applications per farm.
  2. The number of SharePoint web applications per farm.
  3. List of SharePoint Application Pools.
  4. The number of SharePoint application pools.
  5. List of running SharePoint service applications per farm.
  6. The number of running SharePoint service applications per farm.
  7. List of SharePoint content databases per farm.
  8. The number of SharePoint content databases per farm.
  9. List of SharePoint content databases per web application.
  10. The number of SharePoint content databases per web application.
  11. What’s the current content database size?
  12. List of SharePoint site collections per farm
  13. The number of SharePoint site collections per farm.
  14. List of SharePoint site collections per web application
  15. The number of SharePoint site collections per web application.
  16. List of SharePoint site collections per content database.
  17. The number of site collections per content database.
  18. Which content database stores the site collection?
  19. What’s the Site collection size?
  20. List of SharePoint SubSites Per farm.
  21. The number of SharePoint SubSites per farm.
  22. List of SharePoint SubSites per site collection.
  23. Total number of SubSites per site collection.
  24. Farm Report Summary.
SharePoint Farm Scan Report

Download the “SharePoint Farm Scan Report” full script on GitHub.


Applies to
  • SharePoint 2019.
  • SharePoint 2016.
  • SharePoint 2013 / SharePoint 2010.
Download
Conclusion

In conclusion, we have learned the following:

You may also like to read
Have a Question?

If you have any related questions, please don’t hesitate to Ask it at deBUG.to Community.

3 thoughts on “Get All Site Collections and SubSites Per Farm”

  1. Pingback: Get All Content Databases Per Farm | SPGeeks

  2. Pingback: Get All Web Applications Per Farm | SPGeeks

  3. Pingback: PowerShell Script: SharePoint Farm Scan Report | SPGeeks

Leave a Comment

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

Scroll to Top