Set maximum number of site collections per content database
For Particular Requirement, client want to dedicate a database for a single site collection. When we 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 maximum number of site collections on particular content database. Follow steps below :
- Central Administration -> Application Management -> Management Content databases
- Select our 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 we can set the maximum number of sites for the content database.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables for processing
$WebAppURL ="https://sharepointtechnicalsupport.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
}
}
Categories: content DB, powershell command, Site, site collection, website
You must be logged in to post a comment.