{"id":1306,"date":"2012-09-04T11:37:01","date_gmt":"2012-09-04T11:37:01","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1306"},"modified":"2024-04-26T12:27:09","modified_gmt":"2024-04-26T12:27:09","slug":"programatically-setting-site-quota-templates","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/programatically-setting-site-quota-templates\/","title":{"rendered":"Programatically setting Site Quota Templates"},"content":{"rendered":"<h4>Setting Site Quota Templates using PowerShell<\/h4>\n<p>Once sites are created, it can be a challenge to change the quota template. Here\u2019s a way to rip through your site collections and change the quota. In the script below, I grab the Web Application, and go through all the Site Collections, but filter on them using -Match. The trick is to first ensure you are using the Content Service associated with the web application.<\/p>\n<pre lang=\"php\">   $TemplateName = \"MyQuota\"\r\n$webAppName = \"http:\/\/yourWebApp\"\r\n$webApplication = Get-SPWebApplication $webAppName\r\n$sFilter = \"$($webAppName)\/MyPath*\"\r\n \r\n$TemplateName = \"MyQuotaTemplate\"\r\n$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService\r\n$quotaTemplate = $contentService.QuotaTemplates[$TemplateName]\r\n \r\nif ($quotaTemplate -ne $null)\r\n{\r\n$ss = $webApplication.Sites \r\n$sCount = $ss.count\r\nfor ($i =0; $i -lt $sCount; $i++)\r\n{\r\n    $site = $ss[$i];\r\n    if ($site.url -match $sfilter)\r\n    {\r\n        try\r\n        {\r\n            $site.set_Quota($quotaTemplate)\r\n            Write-Host \"Set Quota for $($site.url)\"\r\n        }\r\n        catch\r\n        {\r\n            Write-Host -ForegroundColor DarkRed \"Error setting Quota for $($site.url)\"\r\n        }\r\n    }\r\n    $site.dispose()\r\n}\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Setting Site Quota Templates using PowerShell Once sites are created, it can be a challenge to change the quota template. Here\u2019s a way to rip through your site collections and change the quota. In the script below, I grab the Web Application, and go through all the Site Collections, but filter on them using -Match. [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":1310,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-1306","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1306"}],"version-history":[{"count":1,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1306\/revisions"}],"predecessor-version":[{"id":1315,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1306\/revisions\/1315"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1310"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}