Change SharePoint Site Collection Quota using PowerShell

In some cases, I have seen site collection quotas are turned to “Individual Quota” in the database attachment method, even I copied the quota templates before database attachment. All quota settings are lost! I don’t know the cause of this issue and want to apply the site collection quota to existing sites.

To apply quota for SharePoint site collection using PowerShell, the syntax goes like this:

Set-SPSite -Identity “Site-collection-URL” -QuotaTemplate “Quota-Template-Name”

E.g.

Set-SPSite -Identity "https://sharePoint.company.com/sites/sales" -QuotaTemplate "Gold - 1 GB"

Where “Gold – 1 GB” is our existing quota defined! We can apply quotas in bulk with PowerShell now!

Change quota for SharePoint Site Collections programmatically:

To set site collection quota for SharePoint sites programmatically using PowerShell, The code goes like this:

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
[Void]System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Administration") 

function global:Get-SPSite($url)
{
    return new-Object Microsoft.SharePoint.SPSite($url)
}

$contentService =[Microsoft.SharePoint.Administration.SPWebService]::ContentService

$QuotaTemplate = $contentService.QuotaTemplates["Gold - 1 GB"]
$site = Get-SPSite "https://sharepoint.company.com/"
$site.quota=$QuotaTemplate 

Set Individual Quotas using PowerShell:

#Set the site URL variable accordingly!
$SiteURL = "https://sales.crescent.com"

Set-SPSite -Identity $SiteURL -MaxSize 1GB -WarningSize 900MB 

Bulk update SharePoint Site collection quotas:

In another case, Got a requirement to change the quota template for all site collections under a specific managed path (say: Departments)

$WebAppURL = "https://sharepoint.crescent.com"

$TemplateName ="Gold - 1 GB"

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$quotaTemplate = $contentService.QuotaTemplates[$TemplateName]

Get-SPWebApplication $WebAppURL | Get-spsite -limit all | Where-Object {$_.ServerRelativeUrl.StartsWith("/departments/")} |  ForEach-Object { $_.Quota = $quotaTemplate }


To Remove a Quota Assigned (either via Quota Template or Individual Quota) to a Site collection, Use:

$Site = Get-SPSite -Identity "https://your-site-collection.com/"
$Site.Quota = $null           


SharePoint 2007 – Set quotas in Bulk with STSADM:
We can set site collection quota in bulk using stsadm -o updatequota command line.

E.g. stsadm -o updatequota -quotaname “Name of the Quota defined in Central Admin” 
It’s also possible to limit the quota changes within a content database.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “Change SharePoint Site Collection Quota using PowerShell

Leave a Reply

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