SharePoint 2010: Finding the largest document library in a site collection

SharePoint 2007 came with a page (storman.aspx) dedicated to showing you how much space each of the lists in your site collection were taking up. SharePoint 2010 removed this page. Luckily, SharePoint 2010 SP1 added it back in. But what if you’re still haven’t updated to SP1 and you’re getting warnings/errors about running out of space?

Obviously – up the space so as to avoid additional noise from your users. Then – figure out which libraries are taking up the most space. This can be done by using the (now obsolete – but working) StorageManagementInformation method off of SPSite. You can write some C# to use it, or you can use PowerShell.

The required arguments for this method (listed below) can be found by looking at the above MSDN link. I’ll also include the potential values that can be found by using Reflector to look at the Microsoft.SharePoint dll:

  1. ltVar: What kind of storage management information to display
    • List = 1
    • DocumentLibrary = 2
    • Document = 3
  2. sordVar: the direction in which the items are to be sorted
    • Increasing = 0×10
    • Decreasing = 0×11
  3. soVar: whether the items are sorted by size or by date
    • Size=0
    • Date = 1
  4. nMaxResults: the number of results to return

So if you want to find the top 5 largest document libraries in a specific site collection, here’s the PowerShell:

$site = Get-SPSite "http://yoursitecollection:portifneeded";
$dataTable = $site.StorageManagementInformation(2,0x11,0,5);
$dataTable | Select *

This is very helpful if you aren’t yet on SP2010 SP1. A note though – the method is marked as obselete with this description “SPSite.StorageManagementInformation is expensive; avoid using it.”. There’s no further explanation on what is being spooled up to execute the method or why it was OK in SP2007 but not SP2010. So I’d consider this OK to use if you have to…but not in some kind of recurring scheduled script. Your mileage may vary, I’m not responsible for what happens to your farm, etc. etc.

Hope you found this useful. Let me know!

8 thoughts on “SharePoint 2010: Finding the largest document library in a site collection

    1. Jon Badgett Post author

      Just tried it here (again) on a SharePoint 2010 SP1 environment and it’s working. The line that calls StorageManagementInformation should take a moment (or several) to complete. The only way I was able to then get nothing displayed when I typed the Select * line was if I mispelled the variable I was selecting from (like $dataTbl | Select *). Check your spelling and try again.

      It could also be that whatever computes these metrics (I haven’t found what yet in my limited search) hasn’t been run in your environment. But it could also be a realtime query and this wouldn’t matter at all…

      Reply
  1. Tina

    Thanks it worked now. Can you please let me know how you get this parameters for this StorageManagementInformation(2,0×11,0,5)

    When I checked the MSDN article you mentioned above it doesnt give you number that you have put in braces.

    Reply
  2. Pingback: SharePoint 2010: Como determinar el espacio ocupado de un sitio (I)! - Blog del CIIN

  3. Pingback: SharePoint 2010: Como determinar el espacio ocupado de un sitio (I)! « Pasión por la tecnología…

  4. Pingback: Get The Size of a Document Library | SharePointed

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>