SharePoint Powershell Script to create, update, delete and assign site Quota template
In this Post I am sharing Powershell Script to create, update, delete and assign site Quota template. Its a simple process hope you will find this post interesting. The Script works for both SharePoint 2010 and SharePoint 2013.
Create a new Quota template:
$NewQTemp = New-Object Microsoft.SharePoint.Administration.SPQuotaTemplate
$newQTemp.Name = “Quota Temp1”
$newQtemp.StorageMaximumLevel = 104857600
$newQtemp.StorageWarningLevel = 94371840
$newQtemp.UserCodeMaximumLevel = 300
$newQtemp.UserCodeWarningLevel = 300
$Q =[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$Q.QuotaTemplates.Add($newQtemp)
$Q.Update()
Note: Value for StorageMaximumLevel and StorageWarningLevel is in bytes, so if you want 100 mb it will be 10010241024.
Delete a Quota template:
$q =[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$q.QuotaTemplates.Delete(“Quota Temp1”)
Update code level and storage limit of existing Quota template:
$c =[Microsoft.SharePoint.Administration.SPWebService]::ContentService
$QTemp = $c.QuotaTemplates[“Quota Temp”];
$QTemp.Name = “Quota Temp”
$QTemp.UserCodeMaximumLevel = 500
$Qtemp.StorageMaximumLevel = 115343360
$c.Update()
Note: Increased the Quota template from 100 mb to 110 mb and UserCodeMaximumLevel to 500
In Central Admin we see
Assign a Quota template to a site Collection:
(Note Quota can only be assigned to site collection and not web application or subsite)
$QTemp = “Quota Temp1”
$site = “http://synhnjseza1181:20000/sites/upload”
Set-SPSite -Identity $site -QuotaTemplate $quotaTemplate
In Central Admin we see
Hope this will help you all. 🙂