Individual MySite Quotas

Had a request from a user who had run out of space for storing documents in their MySite.  One of the fun side effects of this in MOSS 2007 is that you can’t use the GUI to change the quota allocated – it throws the standard SharePoint error.

Because the MySite is a Site Collection, you can change the quota on an individual basis.  I knocked together a short console app in Visual Studio 2008.

Build and run it from the Command Line using the syntax:

SiteQuotaChange.exe -url %URL% -quotaname %QUOTANAME%

Notes:
1. Because %QUOTANAME may be something like “Personal Site”, you need to put the quota name in ” marks if it contains a space.
2. If you get %QUOTANAME% wrong, MOSS 2007 will default back to “Individual Quota” with no space allocated.

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace SiteQuotaChange
{
class Program
{
private static string url = String.Empty;
private static string quotaName = String.Empty;

static void Main(string[] args)
{
try {
GetArgs(args);
if (url == String.Empty || quotaName == String.Empty || args.Length > 4)
{
Console.WriteLine("Usage: sitequotachange -url %URL% -quotaname %QUOTANAME%");
}
else
{
using (SPSite site = new SPSite(url))
{
SPWeb web = site.OpenWeb();
Console.WriteLine("Before: " + site.Quota.StorageMaximumLevel);
web.AllowUnsafeUpdates = true;
web.Update();
site.Quota = SPWebService.ContentService.QuotaTemplates[quotaName];
web.Update();
Console.WriteLine("After: " + site.Quota.StorageMaximumLevel);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Exception thrown: {0}, {1}", ex.GetType(), ex.Message);
}
Console.WriteLine();
Console.WriteLine("Finished, press any key");
Console.ReadKey();
}

private static void GetArgs(string[] args)
{
for (int i = 0; i < args.Length; i++)
{
switch (args[i])
{
case "-url":
url = args[i+1];
break;
case "-quotaname":
quotaName = args[i + 1].Replace("\"", "");
break;
}
}
}
}
}

Advertisements

Posted on October 12, 2012, in SharePoint and tagged , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: