kwizcom banner advertisement

Create SharePoint Quota Templates using PowerShell

SharePoint quota templates enables us to keep the site collections growth in control. It defines the maximum amount of data stored in a site collection and prevent from disk fillings! Quota template makes it easier to govern site collections growth by assigning a pre-defined sizing template to them, rather assigning individual quotas to each site collections in the farm. Quota templates set how much storage space a site collection can occupy.

Quota templates offer two levels: Warning Level and Maximum Storage Level.Once the site collection reaches warning level, SharePoint triggers an Email to site collection administrators and further addition to site is possible until it reaches to Maximum storage level.

How to Create a New Quota Template in SharePoint 2010?
Creating new quota template in SharePoint 2010 is relatively simpler! Go to:
  • Central Administration >> Application Management
  • Click on "Specify quota templates" under "Site Collections" group
  • On the quota templates page click on "Create a new template"
  • Give a Name to your new Quota Template
  • Specify the maximum of storage limit, warning limits of the quota template.
  • Optionally, You can specify the sandboxed code limits
  • Click "OK" to complete creation of new quota template sharepoint create quota template powershell
PowerShell Script to Create New Quota Template in SharePoint:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Function to Create New Quota Template
 function CreateQuotaTemplate ($QuotaName, $MaxLevelMB, $WarnLevelMB)
    {
     $quotaTemplate = New-Object Microsoft.SharePoint.Administration.SPQuotaTemplate
     #Set Quota Name
     $quotaTemplate.Name = $QuotaName
     #Set Maximum & Warning Levels
     $quotaTemplate.StorageMaximumLevel = ($MaxLevelMB*1024)*1024
     $quotaTemplate.StorageWarningLevel = ($WarnLevelMB*1024)*1024
     #Add the Quota Template
     $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
     $contentService.QuotaTemplates.Add($quotaTemplate)
     $contentService.Update()
          
     #Print a Success message
     Write-Host "New Quota Template: $($QuotaName) has been added!"
    }

    #Call the function to Create Quota
    CreateQuotaTemplate –QuotaName "Standard" –MaxLevelMB 250 –WarnLevelMB 200

To Create SharePoint quota template programmatically using C#, Refer: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spquotatemplatecollection.add.aspx

Update an Existing Quota Template using PowerShell:
To update an existing quota template, use this PowerShell script.
Add-PSSnapin Microsoft.SharePoint.PowerShell –ErrorAction SilentlyContinue

#Target quota Name to update
$QuotaName = "Standard"
$ContentService  =[Microsoft.SharePoint.Administration.SPWebService]::ContentService

#Get the Quota Template
$QuotaTemplate = $ContentService.QuotaTemplates[$QuotaName]

#Rename the Quota Template
$QuotaTemplate.Name = "Standard Plus"

#Increase the Maximum size from 250MB to 350MB
$QuotaTemplate.StorageMaximumLevel = (350*1024)*1024
$ContentService.Update()

Write-Host "Quota Template has been updated!" -f Green

PowerShell to Delete a Quota Template from SharePoint:
#Target quota Name to delete
$QuotaName = "Standard Plus"
$ContentService  =[Microsoft.SharePoint.Administration.SPWebService]::ContentService

#Delete the Quota Template
$ContentService.QuotaTemplates.Delete($QuotaName)
$ContentService.Update() 
Create SharePoint Quota Templates using PowerShell Create SharePoint Quota Templates using PowerShell Reviewed by Salaudeen Rajack on 3:51 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.