Tuesday, August 19, 2014

Limit Maximum Number of Site Collections in SharePoint Content Database using PowerShell

By default maximum number of site collections in a SharePoint 2013 content database is set to: 5000 and warning level will be 2000 as initial configurations. Although, technically SharePoint 2013 content database can hold up to 10,000 site collections maximum (2,500 non-Personal site collections and 7,500 Personal Sites, or 10,000 Personal Sites alone), 5000 is the recommended limit!

There are times, you may want to dedicate a database for a single site collection. When you create a site collection from central admin, site is placed automatically in any available content database. To prevent any other sites to be created on the particular content database, We can set the maximum number of sites limit! To set maximum number of site collections on a particular content database, navigate to:

  • SharePoint 2013 Central Administration >> Application Management >> Management Content databases
  • Select your target web application in which the particular content database is attached
  • Pick the target database from the list
  • Now, in the "Manage Content Database Settings" page you can set the maximum number of sites for the content database.
Limit Maximum Number of Site Collections in sharepoint
Make sure your maximum number of sites is greater than or equal to current number of sites.

PowerShell script to set Maximum number of site collection limit:
This setting should be configured for each and every content database attached with the particular web application. When you have large number of  content databases, you can use the below PowerShell script tp set max number of sites in a single stretch.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for processing
$WebAppURL ="https://Hosting.Crescent.com"
$MaxSiteCount=1
$WarningSiteCount = 0

#Get all content databases of the web application
$ContentDBColl = Get-SPContentDatabase -webapplication $WebAppURL

#Iterate through each database in the web application
foreach($Database in $ContentDBColl) 
{
    #Check the current No. of sites 
    if($MaxSiteCount -ge $Database.CurrentSiteCount)
    {
        #Set Maximum Sites, warning level Counts
        Set-SPContentDatabase -Identity $Database.Name -MaxSiteCount $MaxSiteCount -WarningSiteCount $WarningSiteCount
        Write-host "Max Sites Settings updated for the database:" $Database.name -ForegroundColor Green
    }
    else
    {
        write-host "MaxSiteCount must be > = current site count! No changes made in $($Database.Name)" -ForegroundColor Red
    }
}



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...