Skip to main content

List Quota and Locklevel of all Site Collections in Farm

Here is another small utility requested in one of the SharePoint newsgroups.

It creates a tab delimited list of all the Site Collections in the current farm

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
  
namespace ListQuotas
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Site Coll name\tSite Coll Url\tIs ReadLocked\tIs WriteLocked\tQuota in bytes");
            SPSecurity.RunWithElevatedPrivileges(delegate
            {
                foreach (SPWebApplication webapp in SPWebService.ContentService.WebApplications)
                {
                    foreach (SPSite sitecoll in webapp.Sites)
                    {
                        Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}",
                            sitecoll.RootWeb.Title,
                            sitecoll.Url,
                            sitecoll.ReadLocked,
                            sitecoll.WriteLocked,
                            sitecoll.Quota.StorageMaximumLevel);
                        sitecoll.RootWeb.Dispose();
                        sitecoll.Dispose();
                    }
                }
            });
        }
    }
}

The executable can be found here and the source code here

Copyright © 2007-2022