Partager via


Changing Quota Template Names in SharePoint V2

Quota Template is a nice feature that's very helpful for SharePoint administrators. It helps in managing your SharePoint server and having total control over how much your site grows.

There was a request to figure-out a way to change the Quota Template name. "Figure-out"?? Huh! what does that mean? Quite surprisingly, there isn't a direct way to change the quota template name in SharePoint. And that was the birth of the below hack!

SPGlobalAdmin globalAdmin = new SPGlobalAdmin();

SPGlobalConfig globalConfig = globalAdmin.Config;

SPQuotaTemplateCollection templates = globalConfig.QuotaTemplates;

foreach(SPQuotaTemplate template in templates)

{

if(template.Name == “Personal Site”)

{

template.Name = “Modified Personal Site”;

template.Add(template);

Console.WriteLine(“Quota Template name changed!!”);

break;

}

}

If you have a look at the above code carefully, it looks like I’ve added a new quota template, but it's actually not the case. However, if you try a direct template.Name = “somename” and then call the Update() method, it wouldn’t work. The break; statement is there to break off from the loop immediately after the change is done. Otherwise, you might see from exceptions thrown at your face J

Comments