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
$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
write-host "MaxSiteCount must be > = current site count! No changes made in $($Database.Name)" -ForegroundColor Red
The error message in sharepoint management shell was as per below screenshot.
UserProfileApplicationProxy.ApplicationProperties ProfilePropertyCache does not have XXXXXXXXXX
It was found that user account running this command has lack of permission in user profile service application. navigate to User Profile Service from central admin and under the tab Permissions give proper permission.