Thursday, August 15, 2013

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 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 2010 create quota template
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 a Quota Template:
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

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

#Delete the Quota Template
$ContentService.QuotaTemplates.Delete($QuotaName)
$ContentService.Update() 



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...