We are planning to apply quotas on our site collections of about 60 which are already created in our web application . i thought of achieving that using power shell but we are facing a small problem which is in that 60 site collections i can keep quotas on only 40 site collections as the other 20 will grow rapidly everyday.The only way that i can see the difference is that the managed path of these site collections are different .can anyone please tell me how can i set the quota on a site collection only if it has a manged path 'projects'and leave those which have managed path called 'communities'


My Code Up to now

   function CreateQuotaTemplate ($Name, $MaxLevelMB, $WarnLevelMB)
    $quotaTemplate = New-Object Microsoft.SharePoint.Administration.SPQuotaTemplate
    $quotaTemplate.Name = $Name
    $quotaTemplate.StorageMaximumLevel = ($MaxLevelMB*1024)*1024
    $quotaTemplate.StorageWarningLevel = ($WarnLevelMB*1024)*1024
    $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService

    CreateQuotaTemplate –Name “Power” –MaxLevelMB 300 –WarnLevelMB 280

 # Replace all site collection quotas in a web application with a new template
$TemplateName = "Power"
$WebApplicationUrl = "http://myportal/"

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$quotaTemplate = $contentService.QuotaTemplates[$TemplateName]
$webApplication = Get-SPWebApplication $WebApplicationUrl
$webApplication.Sites | ForEach-Object { try { $_.Quota = $quotaTemplate; } finally { $_.Dispose(); } }
  • Can you post the script you have so far?
    – Dave Wise
    Commented Jun 19, 2012 at 19:26
  • Hi Dave i just edited my question and added my code
    – Anil
    Commented Jun 19, 2012 at 19:34
  • This looks like it only sets the quota on the root site collection. Where is your code to iterate through the other site collections in the web application?
    – Dave Wise
    Commented Jun 19, 2012 at 19:42
  • Sorry Dave i added the wrong function now i added the bulk function..
    – Anil
    Commented Jun 19, 2012 at 19:50

2 Answers 2


Inside your try {} block, you might need something like this to check the URL and only apply the quota to the ones you want.

if ($_.ServerRelativeUrl.ToLower().StartsWith("/projects/")) {
   $_.Quota = $quotaTemplate;
  • HI Dave I am getting the following error can you help me........... Method invocation failed because [System.String] doesn't contain a method named 'ToLowerCase'. At C:\Users\mosssqlservicet\Desktop\Test PowershellScripts\SetQoutaforSC.ps1:29 char:40 + if ($_.ServerRelativeUrl.ToLowerCase <<<< ().StartsWith("/communities/")) { + CategoryInfo : InvalidOperation: (ToLowerCase:String) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
    – Anil
    Commented Jun 19, 2012 at 20:48
  • Sorry about that, it should be just .ToLower()
    – Dave Wise
    Commented Jun 19, 2012 at 20:56

Replace the bottom two lines with something like:

get-spwebapplication $WebApplicationUrl | 
  Get-spsite -limit all | 
  Where-Object {$_.ServerRelativeUrl.StartsWith("/projects/")} |
  ForEach-Object { $_.Quota = $quotaTemplate }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.